Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Unmanaged order ignore

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

    Unmanaged order ignore

    Hello,

    I'm receiving "An order has been ignored since the stop price ‘924.25’ near the bar stamped ‘18.02.2010 14:15:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored." error when sending exit stop order in the attached unmanaged stategy snippet.

    If I comment "ord2 = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopMarket, 5, 0, 929.5, "", "LE2");" line then error doesn't happen (LE2 order is not filled and canceled on next bar).

    Strategy is run over 10.02.2010-20.02.2010 time period, over ES 09-20 5-minute bars, default session.

    Log excerpts from both strategy runs are attached too.

    What am I doing wrong?
    Attached Files

    #2
    Hello glivv,

    It sounds like a buy stop order was below the bar price.

    What is the high and low of the bar of the submission bar and fill bar?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Buy stop entry order is ok, it's sell stop exit order that gets ignored if another buy stop entry order is present.

      18.02.2010 14:15:00 bar where buy entry stop orders are sent
      Code:
          if (Time[0] == entryTime) {
              ord1 = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopMarket, 5, 0, 926.75, "", "LE1");
              // comment line below to remove error
              ord2 = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopMarket, 5, 0, 929.5, "", "LE2");
          }
      has high=924.25 and low=923.50.

      18.02.2010 14:20:00 bar where buy entry stop order is filled and sell exit stop order is sent
      Code:
          if (execution.Order.Name == "LE1") {
              SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, Position.Quantity, 0, 924.25, "", "LX");
          }
      and another buy stop entry order is canceled
      Code:
          if (ord2 != null) {
              CancelOrder(ord2);
              ord2 = null;
          }
      has high=927.00 and low=923.25.

      If
      Code:
      ord2 = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopMarket, 5, 0, 929.5, "", "LE2");
      is commented then error vanishes so it doesn't look like incorrect stop order price.

      Comment


        #4
        Hello glivv,

        The unmanaged approach does not ignore orders.

        This order was rejected in historical data due to an incorrect price.

        To confirm, the 'SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopMarket, 5, 0, 929.5, "", "LE2");' in your first post is the order being rejected is this correct?

        This would be a buy order. Are you wanting to exit a short position with a buy to cover order?

        If you change the price to be 2 ticks above the close price of the bar, does the error still occur?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I thought too that unmanaged approach does not ignore orders but sell exit stop order was ignored, not rejected.

          OrderTrace message is "Strategy 'tstignore/206980550': Ignored SubmitOrderUnmanaged() method at 18.02.2010 14:15:00: BarsInProgress=0 Action=Sell OrderType=StopMarket Quantity=5 LimitPrice=0 StopPrice=924.25 SignalName='LX' FromEntrySignal='' Reason='Invalid order price, please see log tab'".

          Log tab prints "2020-08-15 11:03:04:072|3|4|Strategy 'tstignore/206980550': An order has been ignored since the stop price ‘924.25’ near the bar stamped ‘18.02.2010 14:15:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored."

          Ignored order is LX ("SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, Position.Quantity, 0, 924.25, "", "LX");". Not LE2.

          If LE2 is commented then LX is working correctly.

          Comment


            #6
            Hello glivv,

            I stand corrected. An ignored order actually would make sense for a historical order placed outside of the bar.

            So the order in question is the sell order and not the order from your original post.

            If you change the price to be 2 ticks below the close price of the bar, does the error still occur?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Order in question is order from original post: "I'm receiving ... error when sending exit stop order".

              Exit order is sent from OnExecutionUpdate when LE1 entry order is filled. Fill bar is a bar with 923.25..927.00 range, 924.25 is within that.

              My concern is that there is different behavior based on the number of entry orders sent.
              If two entry orders (LE1,LE2) are sent, exit order is ignored.
              If one entry order (LE1) is sent, exit order is placed.
              Last edited by glivv; 08-17-2020, 10:39 AM.

              Comment


                #8
                Hello glivv,

                Ok you are inquiring about the order submission from your original post.

                Originally posted by glivv View Post
                If I comment "ord2 = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.StopMarket, 5, 0, 929.5, "", "LE2");" line then error doesn't happen (LE2 order is not filled and canceled on next bar.;
                This is a buy order.

                If you submit the order 2 ticks above the close of the bar, does the error still occur?


                EntriesPerDirection would prevent the entries from being submitted once a position is taken, however this would not affect exit orders.

                The message is that the order has an invalid price. Do you still get the message when using a valid price?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  I'm asking about that LE2 buy order because if it's not sent then LX order is valid and not ignored.

                  LE1 and LE2 are sent on 14:15.
                  LX is sent in the OnExecutionUpdate when LE1 is filled, on 14:20 bar.
                  LE2 is not filled and canceled on the 14:20 bar close.

                  With LE2 used, it looks like NT backtester is using previous bar (14:15) close of 923.50 to check for LX price validity.
                  If LX price is set to 923.50 minus 2 ticks then it works.

                  If LE2 is not used at all then LX works as is (924.25 works).

                  Comment


                    #10
                    Hello glivv,

                    To confirm, when placing the order with a valid price the error does not occur?

                    With the unmanaged approach I would not expect any other orders or positions to affect a new order unless the EntriesPerDirection is affected.

                    Are you certain that the order is being submitted at the same time?

                    May we have the output from the prints and TraceOrders from both tests to confirm?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      My understanding that EntriesPerDirection is for managed approach only which doesn't count here.

                      LE1 entry price is 926.75. When it's filled I guess 924.25 (LX price) should be valid.

                      Without LE2 it in fact is.

                      With LE2, I guess NT uses previous bar close (923.50) and thinks it's not. If 923.00 is used for LX price then NT allows it.

                      LE1 and LE2 are in the same code branch in the OnBarUpdate. LX is in the OnExecutionUpdate.

                      You can see code and logs in the original message, attaching them again.
                      Attached Files

                      Comment


                        #12
                        Hello glivv,

                        From the output I can see that events are not happening at the same time.

                        The very first order is being submitted at different times.

                        2020-08-15 11:04:11:040|1|16|OrderTrace: Strategy 'tstignore/206980550': Entered internal SubmitOrderUnmanaged() method at 18.02.2010 14:15:00: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=5 LimitPrice=0 StopPrice=926.75 SignalName='LE1'

                        vs

                        2020-08-15 11:03:04:071|1|16|OrderTrace: Strategy 'tstignore/206980550': Entered internal SubmitOrderUnmanaged() method at 18.02.2010 14:15:00: BarsInProgress=0 Action=Buy OrderType=StopMarket Quantity=5 LimitPrice=0 StopPrice=926.75 SignalName='LE1'

                        Likely the logic in the code has different behavior. It looks like you are submitting an exit when the entry fills. If the entry is never placed and never filled, then the exit wouldn't be submitted and the error would not occur.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Those are not OnBarUpdate times.

                          "2020-08-15 11:04" and "2020-08-15 11:03" are times when I run backtests of 2 versions of the strategy (with LE2 and without LE2).

                          Time in question is 18.02.2010 14:15 (10 years ago).

                          Comment


                            #14
                            Hello glivv,

                            Are you modifying the TraceOrders?

                            Print the time of the bar and not the current computer time so that we can see when the orders are being submitted.

                            Below is a link to a forum post that demonstrates how to use prints to understand behavior and includes a video.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              I've uploaded code where all details could be seen, change and run it to get timestamps/traces/whatever you want.

                              ES 09-20, 5-minute bars. default session, 18.02.2010.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by TraderBCL, Today, 04:38 AM
                              2 responses
                              17 views
                              0 likes
                              Last Post TraderBCL  
                              Started by martin70, 03-24-2023, 04:58 AM
                              14 responses
                              106 views
                              0 likes
                              Last Post martin70  
                              Started by Radano, 06-10-2021, 01:40 AM
                              19 responses
                              609 views
                              0 likes
                              Last Post Radano
                              by Radano
                               
                              Started by KenneGaray, Today, 03:48 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post KenneGaray  
                              Started by thanajo, 05-04-2021, 02:11 AM
                              4 responses
                              471 views
                              0 likes
                              Last Post tradingnasdaqprueba  
                              Working...
                              X