• 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 Newtrader101, Today, 10:31 AM
        0 responses
        3 views
        0 likes
        Last Post Newtrader101  
        Started by rwilliam, Yesterday, 03:55 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by RandanAL, Today, 09:05 AM
        0 responses
        4 views
        0 likes
        Last Post RandanAL  
        Started by cstern71, 09-02-2019, 10:30 AM
        4 responses
        63 views
        0 likes
        Last Post Lancer
        by Lancer
         
        Started by Hanstanz, Today, 04:44 AM
        0 responses
        12 views
        0 likes
        Last Post Hanstanz  
        Working...
        X