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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        577 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X