Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged + OCO + CancelOrder

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

    Unmanaged + OCO + CancelOrder

    Hello,

    When an entry order is filled, I send a bracket order (takeProfit + stoploss) tied by an OCO-ID.
    When one of the two orders is filled the other is canceled. Works fine.

    However, if you cancel before one of the two orders with the CancelOrder function, the other order is not automatically canceled.
    I think it should be automatically canceled because it is an OCO. Is it the way it should work?

    Thanks

    Edit:
    this issue occurs in Historical only. In RealTime works fine.

    Unmanaged = true
    NT7B15
    Last edited by cls71; 05-06-2010, 01:00 AM.

    #2
    cls71, thanks for reporting in and testing - would you mind sharing the snippet you used? You can also contact me directly at support at ninjatrader dot com (Attn Bertrand) to follow up - thanks.

    Comment


      #3
      I sent you an email with the code.

      Thanks

      Comment


        #4
        Originally posted by cls71 View Post
        Hello,

        When an entry order is filled, I send a bracket order (takeProfit + stoploss) tied by an OCO-ID.
        When one of the two orders is filled the other is canceled. Works fine.

        However, if you cancel before one of the two orders with the CancelOrder function, the other order is not automatically canceled.
        I think it should be automatically canceled because it is an OCO. Is it the way it should work?

        Thanks

        Edit:
        this issue occurs in Historical only. In RealTime works fine.

        Unmanaged = true
        NT7B15
        I'm having the same issue now even in 2019. It does not work in an expected way when running Historical simulation.

        For example I have this code that is executed at the end of the bar (lets say 1min timeframe):

        Code:
        testOrder1 = SubmitOrder(0, OrderAction.Buy, OrderType.Stop, 1, 0, Close[0]+100*TickSize, "ocolink", "order1");
        testOrder2 = SubmitOrder(0, OrderAction.SellShort, OrderType.Stop, 1, 0, Close[0]-100*TickSize, "ocolink", "order2");
        Then 1 minute later when I call CancelOrder function on one of those two orders, only the one passed to CancelOrder function is cancelled:

        Code:
        CancelOrder(testOrder1);
        This log is produced (in historical backtesting) when TraceOrders = true;

        First entering orders:
        8. 1. 2019 0:01:00 Entered internal SubmitOrder() method at 8. 1. 2019 0:01:00: Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=49,79 OcoId='ocolink' Name='order1'
        8. 1. 2019 0:01:00 Entered internal SubmitOrder() method at 8. 1. 2019 0:01:00: Action=SellShort OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=47,79 OcoId='ocolink' Name='order2'

        Then calling CancelOrder():
        Cancelled custom managed order at 8. 1. 2019 0:02:00: Order='NT-00000/Backtest' Name='order1' State=Working Instrument='CL 03-19' Action=Buy Limit price=0 Stop price=49,79 Quantity=1 Strategy='HighLow' Type=Stop Tif=Gtc Oco='ocolink' Filled=0 Fill price=0 Token='33747c93686241c999db608955f4b893' Gtd='1. 12. 2099 0:00:00'


        Or is this an expected behavior?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        43 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        158 views
        2 likes
        Last Post CaptainJack  
        Working...
        X