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 DannyP96, 05-18-2026, 02:38 PM
      1 response
      27 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      117 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      69 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      226 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      417 views
      0 likes
      Last Post CaptainJack  
      Working...
      X