Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ignored Order

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

    Ignored Order

    Hello

    I have an ignored order that does not make sense. Here is the message from the output window

    **NT** A Sell stop order placed at '17-Jun-14 2:00:00 PM' has been ignored since the stop price is greater than or equal to close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
    Attached you will find a snippet from the output window and a chart with this trade on the USDJPY.

    On the chart you will find a blue candle that I have named "Signal Candle". (Pay attention only to the blue candle that i have marked - not the other blue candles on the chart) This is the candle that every calculation is based on within this strategy. The Entry orders (there are 2 of them) are placed when this candle closes. The stop orders and the initial profit target is placed when the entry orders have filled. Their placements are based on a percentage of the signal candle As soon as the profit target is hit, then the initial stop order from the second entry is changed and that order is called LongAdjustedStop.

    LongAdjustedStop is the order that is being ignored.

    The blue horizontal line across the chart is the longAdjustedStop price. That is the price that NinjaTrader is calculating based on the Signal Candle and it is correct. The problem is that NinjaTrader is saying that it is equal to or above the closing price of the candle. But, this order does not get called until "LongTarget" is filled which you can see the candle that this happened on and the order is significantly below the close of this candle. The price of the Stop can be seen on the snippet of the output window that is attached.

    Here is the code that is used to enter the LongAdjustedStop order:

    Code:
    			// Set the adjusted stop loss LONG
    			if (LongLimit != null
    				&& LongLimit.OrderState == OrderState.Filled
    				&& LongStopB != null
    				&& LongAdjustedStop == null)
    	
    			{
    				LongAdjustedStop = ExitLongStop(0,true,positionSize,adjustedStopLong,"LongAdjustedStop","LongEntryB");
    				CancelOrder(LongStopB);
    				Print(Time[0] + " Hello, LongAdjustedStop is being called!");
    				LongStopB = null;
    				LongLimit = null;
    			}
    Are you able to help me figure out why this is saying that it is equal to or above the close of the candle when it clearly is not the case? It is equal to or above the previous two candles' closes, but it is not called until LongLimit ("Long Target") is filled.

    Thank you very much for your help.
    Attached Files

    #2
    jg123,

    I strongly recommend that you print out the value of adjustedStopLong in this condition.

    This will let you know at what price the Stop order is being set to and when it gets called.

    Print("Price: " + adjustedStopLong " At time: " + Time[0]);
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      hi Cal

      Thank you very much for your response.

      I have printed it exactly as you mentioned and it is giving me the correct price. I have attached a snippet from the output window that shows that.

      here is where i placed it in the code:
      Code:
      			if (LongLimit != null
      				&& LongLimit.OrderState == OrderState.Filled
      				&& LongStopB != null
      				&& LongAdjustedStop == null)
      	
      			{
      				LongAdjustedStop = ExitLongStop(0,true,positionSize,adjustedStopLong,"LongAdjustedStop","LongEntryB");
      				CancelOrder(LongStopB);
      				Print(Time[0] + " Hello, LongAdjustedStop is being called!");
      				LongStopB = null;
      				LongLimit = null;
      				Print("Price: " + adjustedStopLong + " At Time: " + Time[0]);
      			}
      what would be your thoughts for me to check next?

      Thanks again!
      Attached Files

      Comment


        #4
        Jg123,

        Since, this is a historical trade, the order is being evaluated on the previous bar from the entry.

        Your entry got filled which then caused the OnOrderUpdate() to get called and attempt to place the Stop Order, which at time the close price was below the Stop price of the order and gave you that message.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Okay, that is very good information to know. I really appreciate that.

          Why are trades evaluated on the previous bar from entry?

          This method of evaluating definitely makes it very difficult to know if all of the following trades are being properly executed - and, in fact, they are all messed up and the issue can be directly linked to this error message - which makes it virtually impossible to continue writing the strategy and knowing that everything is working properly. Is there some kind of work around for this? Is this a common problem that people have in NinjaTrader even if their code is written correctly?

          Comment


            #6
            Jg123,

            My suggestion would be to check that the close of the bar is not below or equal to your StopPrice.

            Additionally you could look using a variable that is triggered in OnOrderUpdate that when the next OBU is called it finds that variable true and submits the orders that way.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              okay. Thanks

              I can't change the stop price as that messes up the profitability of the strategy and the reality is, is that the price is not equal to or above the close of the bar that it is to be called on. If I check to make sure that the close is above, first, then I will still be running into issues if the orders are evaluated based on the previous bar.

              Do you have documentation on this so that I can read up more on this concept in order to find out why it is set up like this?

              For your second suggestion, are you saying that I should take the code that I currently have written for this stop and place it is in OnOrderUpdate? It is currently in OnExecution. If that is the case, then I have just tried doing that and have gotten error messages but havent taken the time to debug them because i am not sure yet if I am understanding you correctly.

              Again, thank you very much for your help

              Comment


                #8
                In researching this even more, I have found this quote from NT on bigmike

                A bar is evaluated (which is its closing values), if a signal is then generated, an order is submitted which is then filled on the following bar.
                it comes from this thread and is post #4: https://www.bigmiketrading.com/ninja...njatrader.html

                so this is a little confusing to me as it is talking about backtesting and says that it evaluates each bar as it closes and determines if there is a trade. if there is, then it places the trade on the next bar (unless of course the code uses intrabar granularity - which i am using)

                so the bar before on my chart would not have produced anything so, if I understand that correctly, then it should not be making any calculations. Can you please let me know where I am thinking incorrectly on this?

                Comment


                  #9
                  Jg123,

                  The bar before was the signal for the trade. However, that bar has closed and thus any trades placed are going to show on the next bar as the FillType is looking at the next to see if the trade will get filled or not.
                  However, the order of events here is that the order does get filled and the Stop order is placed, however we are still using the Signal bar's data for the calculation and thus why you get the reject message
                  Cal H.NinjaTrader Customer Service

                  Comment


                    #10
                    Thank you for the answer Cal. Very appreciated!

                    This does still leave me confused unfortunately.

                    I am posting the chart to help illustrate my question a bit.

                    We will name the candles using the C# way of doing it, and we will call the candle that LongEntryA, LongEntryB and Long Target were filled on as "Close[0]". It is the USDJPY 1 Hour chart and the 15:00 TimeStamp. That means that the blue signal candle is Close[11].

                    If I am understanding you correctly, then you are saying that Close[1] is what signaled the trade and then it was actually filled on Close[0].

                    Unfortunately, Close[1] would not have triggered any orders.

                    Close[11] (The Signal Candle in Blue) at the candle close would have caused two BuyStop orders to be placed at 102.07'5. and a ExitLongStop order at 101.85. Nothing will happen until the price gets above the high of the Signal Candle (Close[11]) which is up to 102.07'5 - it does not do that until Close[0]. Therefore Close[1] would not have triggered any actions. On Close[0] the entry orders would have been triggered and filled and then also Long Target would have been triggered and filled.

                    It is not until "Long Target" is filled that "LongAdjustedStop" is placed at 102.04'2. LongTarget executes and gets filled on Close[0] so the previous candle has nothing to do with the placement of LongAdjustedStop. LongAdjustedStop is not even a consideration in the code when the previous candle (Close[1]) is trading. The soonest that the code would even start looking at LongAdjustedStop would be Close[0], in which case, the price is well below the close of the candle.

                    Does it change things if I mention that I am using intrabar granularity?

                    Can you please let me know if I understood you correctly with your answer? If I have, can you please help me understand how the previous candle would have made any effect on the code as nothing can happen until LongEntryA & LongEntryB get triggered.

                    Attached is also the code filled with comments in each of the sections of live code to make really clear what I am doing in each spot and you will be able to see exactly each order should get activated.

                    Thank you very much for your help. This is an incredibly important issue for me to get resolved because it is significantly effecting my ability to move things forward.
                    Attached Files

                    Comment


                      #11
                      Hello, I am just wondering if we have an update on this.

                      Thank you very much!

                      Comment


                        #12
                        Hello jg123,

                        Thank you for your response.

                        Could you advise what time zone your PC is set to?

                        The intra-bar granularity being simulated with the 1 Minute bar should have no effect on the LongAdjustedStop as it is being submitted to the primary series.

                        Comment


                          #13
                          Hi Patrick.

                          Thank you very much for getting back to me.

                          It is set to Berlin time (UTC +1)

                          Okay, I didn't think that it would make a difference, but I am not always completely sure with Intrabar granularity. Thanks for the clarification

                          Comment


                            #14
                            Hello jg123,

                            Thank you for your response.

                            I wanted to cross reference that to my chart, so thank you for providing the time zone. So the next step here, going in line with what you are already working with Cal on, is to Print() the Close[0] at the same time that you Print() the Time[0] and adjustStopLong.

                            Please provide the Output in your response and the code used after completing the above.

                            Comment


                              #15
                              Hi Patrick

                              Thank you very much for this. This has definitely made clear that the order is higher than the close. I am attaching the Output window screenshot to show that. It leaves me confused beyond words, though.

                              The output window shows that longAdjustedStop is being correctly placed at 101.996 but it is showing the close at 101.98 which is, as the error says, lower than the stop price.

                              You also asked for the code that I used to do the task, so here is that. It is found in OnExecution:

                              Code:
                              			if(LongEntryA != null
                              				&& LongEntryB != null
                              				&& LongEntryA.OrderState == OrderState.Filled
                              				&& LongEntryB.OrderState == OrderState.Filled)
                              			{
                              				LongStopA = ExitLongStop(0,true,positionSize,SMA(sMAPeriod)[0] - ((signalHigh - signalLow) * StopPerc),"LongAStop","LongEntryA");		
                              				LongStopB = ExitLongStop(0,true,positionSize,SMA(sMAPeriod)[0] - ((signalHigh - signalLow) * StopPerc),"LongBStop","LongEntryB");
                              				Print(Time[0] + " Stop orders are placed.");
                              				Print(Time[0] + " LongStopA = " + LongStopA);
                              				Print(Time[0] + " LongStopB = " + LongStopB);
                              				Print(Time[0] + " LongAdjustedStop will be " + adjustedStopLong);
                              			}
                              			Print(Time[0] + " Close = " + Close[0] + " AdjustedStopLong is " + adjustedStopLong);
                              Attached is the picture which shows the candle that closes at 101.98. And, it is just as Cal stated.

                              I just can not, for the life me, understand why it would possibly be computing my adjusted stop on this candle. My code clearly states that it should be only computing and placing that after the long target (in the code it is LongLimit) is filled. It is especially confusing as there is no code at all that tells it to do anything after the entry orders are placed until they are actually filled. Then everything else happens and they are not filled until the candle following this one that is causing the error.

                              Here is that code that shows that LongAdjustedStop doesn't get called until after LongLimit is filled:
                              Code:
                              			if (LongLimit != null
                              				[COLOR="Red"][B]&& LongLimit.OrderState == OrderState.Filled[/B][/COLOR]
                              				&& LongStopB != null
                              				&& LongAdjustedStop == null)
                              	
                              			{
                              				LongAdjustedStop = ExitLongStop(0,true,positionSize,adjustedStopLong,"LongAdjustedStop","LongEntryB");
                              				CancelOrder(LongStopB);
                              				Print(Time[0] + " Hello, LongAdjustedStop is being called!");
                              				LongStopB = null;
                              				LongLimit = null;
                              				Print("Price: " + adjustedStopLong + " At Time: " + Time[0]);
                              			}
                              Can you please help me to adjust the code accordingly? Though, it may be possible that all of the code will work properly when going live, but I can not debug this and know that things are working properly with this kind of an error. Therefore I can not keep adding the next layers of this strategy because I am not confident that everything in this layer is working correctly.

                              Thank you for all of the help that you guys have given so far. Definitely appreciated!!
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              656 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              371 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              579 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X