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 argusthome, 03-08-2026, 10:06 AM
      0 responses
      80 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      45 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      29 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      32 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      66 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X