Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Tradestation/Ninja Order timing.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Tradestation/Ninja Order timing.

    In Tradestation, if I enter a position, and place a Profit and stop, when I reach one of those, the other is automatically canceled.

    For example:
    if AverageFC(10) crosses over AverageFC(100) then
    buy next bar at market;

    if marketposition = 1 then begin
    sell next bar at entryprice + 10 limit;
    sell next bar at entryprice - 10 stop;
    end;

    When one of the 2 exit orders is hit, the other is IMMEDIATELY cancelled.

    However, if I use the following EL code, the other order is not canceled until the beginning of the next bar.

    if lastbaronchart and NTConnected(1) then begin
    if AverageFC(10) crosses over AverageFC(100) then
    NTBuyMarket("LE",1);

    if NTmarketposition("") > 0 then begin
    NTSellLimit("LPT",entryprice + 10, 1);
    NTSellStop("LStop",entryprice - 10, 1);
    end else begin
    NTCancel("LPT");
    NTCancel("LStop");
    end;
    end;

    I appreciate your help in advance!

    #2
    Forgot to mention, this is all running in simulation mode.

    Comment


      #3
      sgordon77,

      That is because your orders are not submitted as OCO orders. Your cancellation command is not sent until the next bar that is why you don't see it till the next bar. If you want OCO you need to use NTCommand to submit your orders.
      Josh P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      59 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      36 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      22 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      10 views
      0 likes
      Last Post cre8able  
      Working...
      X