Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order sequence

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

    Order sequence

    Hello,

    I've coded the following to place discrete orders:
    Code:
    public Order[] MyEnterLongLimit(double LimitPrice, double ProfitTargetTicks, double StopLossTicks)
    
    {
    
    Order[] Orders = {null,null,null};
    
    Orders[0] = ExitLongStopMarket(Close[0] - (StopLossTicks*TickSize),"SL");
    
    Orders[1] = EnterLongLimit(Close[0]);
    
    Orders[2] = ExitLongLimit(Close[0] + (ProfitTargetTicks*TickSize),"PT");
    
    return Orders;
    
    }
    ​
    I expect Orders[1] to be filled first (long entry order), then Orders[2] (profit target), in worst case then Orders[0] (stop loss)

    When profit target is filled, how do I cancel the stop loss? (or vice versa)

    Many Thanks, Caesar.

    #2
    Hello Skechers,

    Thank you for your note.

    Unfortunately, what you have there wouldn't work as you would expect. Exit orders will be ignored until there is a position to be exited, which means you need to first submit your entry order, wait for it to fill, and then submit the exit orders for the position.

    Exit orders will be automatically cancelled when the position they were meant to exit is closed.

    I would take a look at this example from our help guide which goes over submitting exit orders for stops and targets immediately on the entry order filling:



    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Many Thanks Kate!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      39 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      19 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      26 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      36 views
      0 likes
      Last Post CarlTrading  
      Working...
      X