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 pechtri, 06-22-2023, 02:31 AM
        9 responses
        122 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by frankthearm, 04-18-2024, 09:08 AM
        16 responses
        65 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by habeebft, Today, 01:18 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by benmarkal, Today, 12:52 PM
        2 responses
        13 views
        0 likes
        Last Post benmarkal  
        Started by f.saeidi, Today, 01:38 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X