Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT checking my stop order price against the wrong timeframe Bar

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

    NT checking my stop order price against the wrong timeframe Bar

    From what I can tell, it appears that NinjaTrader is checking the stop order prices against the Close of the higher timeframe bar when I am submitting the orders on the lower timeframe.

    From TraceOrders, it seems that it is also logging the time of the correct timeframe bar in the log statements (00:11:00), but the error log line shows the time of the incorrect bar (00:00:00):

    01/02/2000 00:11:00 Entered internal PlaceOrder() method at 01/02/2000 00:11:00: Action=BuyToCover OrderType=Limit Quantity=0.1M LimitPrice=0.9700'5 StopPrice=0 SignalName='X S @LMT' FromEntrySignal='Enter S'
    01/02/2000 00:11:00 Entered internal PlaceOrder() method at 01/02/2000 00:11:00: Action=BuyToCover OrderType=Stop Quantity=0.1M LimitPrice=0 StopPrice=0.9711'5 SignalName='X S @STP' FromEntrySignal='Enter S'
    **NT** A BuyToCover stop order placed at '01/02/2000 00:00:00' has been ignored since the stop price is less than or equal to the close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
    01/02/2000 00:11:00 Ignored PlaceOrder() method at 01/02/2000 00:11:00: Action=BuyToCover OrderType=Stop Quantity=0.1M LimitPrice=0 StopPrice=0.9711'5 SignalName='X S @STP' FromEntrySignal='Enter S' Reason='Invalid order price, please see log tab'

    I have a high timeframe as the primary timeframe, and I add the One Minute timeframe in the initialization() method. Perhaps it is meant to be the lowest timeframe is first?

    Or is this a known bug?

    #2
    I have successfully worked around this issue by programming my strategy to check its stop prices against the primary bar instead of the 1min bar.

    I think this shows that there must be something amiss in the NT order validation.

    Comment


      #3
      adamus, could you please post your strategy so we can check to see if this is actually a bug?
      AustinNinjaTrader Customer Service

      Comment


        #4
        Austin,

        I have just sent the strategy and associated files to you in a zip attachment to an email.

        You will have to revert the work-around to demonstrate the bug, and you should test it on $EURUSD from 2000 to present day with a 30min timeframe.

        The work-around is in 4 places: file OrderStruct, lines 200, 219, 250 and 265.

        Change the code to check the 1min timeframe bar instead of the default BarsInProgress=0 bar.

        Code:
        //work-around: 
        if (this.price <= this.parent.Closes[0][0])
        
        //desired correct code:
        if (this.price <= this.parent.Closes[this.timeFrame][0])
        This is the code for buying - swap for the < for a > for selling on the other lines.

        There is another issue that I have, discussed in a different thread. The guys there also wanted the code so I'll direct them to you.
        Last edited by adamus; 08-08-2010, 11:02 AM.

        Comment


          #5
          Hi there, I've received the files and will be taking a look on Monday. Thank you.
          AustinNinjaTrader Customer Service

          Comment


            #6
            adamus, your code compiled and ran fine, unfortunately I'm not sure exactly what to look for. Would it be possible for you to create a very stripped down strategy that just demonstrates the stop being checked from the wrong data series? If not, could you please let me know of a specific date/bar that shows this? A ten year backtest generates a whole bunch of output, and it is hard to sift through it all...
            AustinNinjaTrader Customer Service

            Comment


              #7
              Austin,

              see the date on the logs in the first message. It's $EURUSD. Run it for year 2000 on 30 mins bars. You should see the **NT Error** like the copy I pasted in above.

              Comment


                #8
                adamus, unfortunately we don't have access to historical forex data that far back. The first time I ran it I specified the whole 10 year backtest, but only 5 years of data was downloaded, which I didn't notice until just now. Can you either zip up the appropriate data and upload it to something like sendspace.com or find a different data (in the last 5 years) where this occurs?
                AustinNinjaTrader Customer Service

                Comment


                  #9
                  Hi Austin, after wasting a fair amount of time trying to upload a 300mb file to sendspace.com, I re-ran the strategy and the issue occurs in every market in every year I ran it on.

                  Just run it from 2009 to present on $EURUSD and watch out for that **NT Error** statement in the output window or the control center log.

                  Comment


                    #10
                    **NT** A Sell stop order placed at '19/06/2009 10:00:00' 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.

                    Comment


                      #11
                      adamus, are you submitting your stop orders to the correct BarsInProgress index? How are you setting your stop loss? Are you checking if the price is valid before sending the order?
                      AustinNinjaTrader Customer Service

                      Comment


                        #12
                        Of course. That's why I think there's a bug. It's all obvious in the code. Well perhaps not so obvious but it's all in there.

                        Comment


                          #13
                          I am sorry, but it's not very obvious to me due to the use of many helper classes and methods. I do see how the stops are submitted,
                          Code:
                          this.order = this.parent.EnterLongStop(this.timeFrame, true, this.quantity, this.price, this.orderLabel);
                          but you will have to completely break this strategy down to the bare basics (as in only one strategy script and no variables in the stop submission) so we can understand exactly what could be going wrong.
                          AustinNinjaTrader Customer Service

                          Comment


                            #14
                            Maybe I was being a bit too self-deprecatory with my comments about my code and put you off.

                            I know it's not the greatest job to trace through someone else's code, but I'm not in a position to recode the whole thing at this point, so if you won't or can't trace through it, then that's were this thread stops.

                            If I do get a spare couple of hours I'll recode it for you, but it won't be anytime soon, and I will be very surprised if I find out that it's my fault and not NT7.

                            You might have seen all the logging I do. I can see 95% of what is going on in my code as it runs, and plus with the output from TraceOrders, I can see that TraceOrders picks up the right timeframe, but when the OrderUpdate and Execution events are fired, the BarsInProgress is showing the other timeframe.

                            Comment


                              #15
                              Thank you for your time on this issue, adamus. Your assistance is greatly appreciated. If you do come up with a smaller strategy to demonstrate this, we'd love to see it.
                              AustinNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              591 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              343 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              556 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              553 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X