• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.

    http://www.ninjatrader.com/support/h...gyuniqueid.htm

    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", orderId2);
        Code:
        SubmitOrder(int barsInProgressIndex, OrderAction orderAction, OrderType orderType, int quantity, double limitPrice, double stopPrice, string ocoId, string signalName)
        http://www.ninjatrader.com/support/h...ubmitorder.htm

        You may want to switch them around.
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by billythekid72, Today, 09:47 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by JohnS52, Today, 09:49 AM
        0 responses
        6 views
        0 likes
        Last Post JohnS52
        by JohnS52
         
        Started by DTSSTS, Today, 08:29 AM
        2 responses
        17 views
        0 likes
        Last Post DTSSTS
        by DTSSTS
         
        Started by mtamaku, Today, 08:39 AM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Douglee, Today, 08:11 AM
        2 responses
        13 views
        0 likes
        Last Post Douglee
        by Douglee
         
        Working...
        X