Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanaged orders

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

    Unmanaged orders

    Hi, i have problem with unmanaged orders. If I start strategy at first time and open orders like this:
    Order2 = SubmitOrder(0 , OrderAction.Buy, OrderType.Stop, LotSize, 0, Price1var, "Long", "Enterlong");
    Order1 = SubmitOrder(0 , OrderAction.Sell, OrderType.Stop, LotSize, 0, Price2var, "Short", "Entershort");

    that work right. But If i close strategy and run it again, orders are sent to broker and immediately are canceled with this error:
    Order rejected - reason: The OCA group order has alreadt been filled. (201).

    But there are no opened order, could you help me please? Thank you

    #2
    Hello hanysfx,

    This may be expected depending on what broker provider you use as you are submitting the orders again with the same OCO Id. You may want to generate a unique OCO Id each time like "GetAtmStrategyUniqueId()" or your own method.



    Let us know if that helps.
    JCNinjaTrader Customer Service

    Comment


      #3
      My broker is Interactive Brokers.
      I changed code to this:
      string orderId1 = GetAtmStrategyUniqueId();
      string orderId2 = GetAtmStrategyUniqueId();

      Order2 = SubmitOrder(0 , OrderAction.Buy, OrderType.Stop, LotSize, 0, Price1val, "Long", orderId1);
      Order1 = SubmitOrder(0 , OrderAction.Sell, OrderType.Stop, LotSize, 0, Price2val, "Short", orderId2);

      and there is same error.

      Comment


        #4
        Hello hanysfx,

        The "OCO Id" is going to be the second one from the last, not the last one.

        Code:
        Order1 = SubmitOrder(0 , OrderAction.Sell, OrderType.Stop, LotSize, 0, Price2val, "Short", [B]orderId2[/B]);
        Code:
        SubmitOrder(int barsInProgressIndex, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice, [B]string ocoId[/B], string signalName)


        You may want to switch them around.
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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