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 josh18955, 03-25-2023, 11:16 AM
        6 responses
        435 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        3 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        18 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frslvr, 04-11-2024, 07:26 AM
        9 responses
        127 views
        1 like
        Last Post caryc123  
        Started by selu72, Today, 02:01 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Working...
        X