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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      308 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      199 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      186 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      275 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      229 views
      0 likes
      Last Post CarlTrading  
      Working...
      X