Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Yet another issue with: "An order has been ignored..."

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

    Yet another issue with: "An order has been ignored..."

    Ok, so I'm trying to backtest my strategy in the Strategy Analyzer and when submitting a Stop order I'm getting that error "An order has been ignored since the stop price X near the bar stamped Y is invalid based on the price range of the bar."

    - I don't get any errors in playback mode.
    - The main (triggering) order is being placed in OnBarUpdate().
    - The stop is being placed with ExitLongStopMarket() in OnExecutionUpdate()
    - The Strategy Analyzer is set to use "Tick Reply"

    From all the old posts about this error that I found, I would think that using Tick Reply would avoid this issue. But apparently not.

    One solution I saw was to use High Order Fill Resolution set to 1 Tick, but I'm using multiple data series, so I can't do that. I assume "Tick Replay" is basically the same thing? (Yes?)

    I'm printing some info inside the OnExecutionUpdate() method, right before trying to set the stop order...
    - The main (long) order has a fill price of 4276
    - Trying to place the stop order at 4273
    - The H/L/C of the current bar (using High[0], Low[0] and Close[0]) print out H:4276, L:4272 and C:4276 --- so even though the stop is above the low of the bar, it's still below the current price (the close)

    Questions:
    - Shouldn't using Tick Reply allow this?
    - Is using High[0], Low[0] and Close[0] "accurate" per tick when using Tick Reply (rather than the High/Low/Close of the finished bar)?
    - Is using Close[0] a valid way to get the current price or is there a better way?

    Any ideas?

    Thanks!

    In case it's helpful, here are my Backtest settings:

    Click image for larger version

Name:	image.png
Views:	721
Size:	33.5 KB
ID:	1284837

    #2
    Hello GregX999,

    Thank you for your post.

    Although Tick Replay allows for intrabar actions, it does not introduce more granular price data for order fills. This means that order fills are still based on the OHLC values of a bar. You mentioned the following:
    - The main (long) order has a fill price of 4276
    - Trying to place the stop order at 4273
    - The H/L/C of the current bar (using High[0], Low[0] and Close[0]) print out H:4276, L:4272 and C:4276 --- so even though the stop is above the low of the bar, it's still below the current price (the close)
    ​Please refer to the "Understanding the Historical Fill Algorithm" graphics on this page:


    The historical bars are broken into three virtual bars depending on whether the Open is close to the High price or the Low price of the bar. If your stop order ends up on the wrong side of the market for the first virtual bar of the three that the bar gets broken down into, this can result in the order being ignored based on the price range of the virtual bars that are created. Since High Order Fill Resolution is not an option with your multi-series script, you will need to introduce intrabar granularity programmatically by adding a 1-tick data series and submitting orders to that added series. We have a reference sample demonstrating this concept here:


    The following forum threads also cover this concept:
    I am coding a strategy and am receiving numerous instances of the following error message: A Buy order placed at '[time]' has been ignored since the stop price is less than or equal to the close price of the current bar. I have searched the NinjaTrader forums and have read many posts related to this error message, but none

    Hello Support, I have been getting this error in the NT LOG running a strategy against NQ 03-21, using Strategy Analyzer Strategy 'cscCTMacdv02/-1': An order has been ignored since the stop price ‘12364.75’ near the bar stamped ‘2020-12-09 7:50:00 PM’ is invalid based on the price range of the bar.


    The following forum post discusses the purposes of using Tick Replay and intrabar granularity in backtests. You can do both with an added 1-tick data series for intrabar granularity and also Tick Replay enabled for intrabar actions:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Is there a prescribed/preferred way to handle this kind of situation for back-testing? (Placing stops within the range of the current bar, even though they are on the correct side of the current price?)

      I tried having my strategy recognize it's running in "backtest mode", and if so, manually close positions when a stop-price is hit (instead of using actual Stop orders), but then I noticed something else... When opening or closing a position with methods such as EnterLong() or ExitLong(), when looking at the chart view in the Strategy Analyzer, I can see that the orders are executing on the Open of the bar rather than on the price at the time of entering/exiting. This is making the Stratagy Analyzer basically useless for me.

      What am I doing wrong?

      Comment


        #4
        Originally posted by GregX999 View Post
        Is there a prescribed/preferred way to handle this kind of situation for back-testing? (Placing stops within the range of the current bar, even though they are on the correct side of the current price?)

        I tried having my strategy recognize it's running in "backtest mode", and if so, manually close positions when a stop-price is hit (instead of using actual Stop orders), but then I noticed something else... When opening or closing a position with methods such as EnterLong() or ExitLong(), when looking at the chart view in the Strategy Analyzer, I can see that the orders are executing on the Open of the bar rather than on the price at the time of entering/exiting. This is making the Stratagy Analyzer basically useless for me.

        What am I doing wrong?
        "Is there a prescribed/preferred way to handle this kind of situation for back-testing?"
        The two possibilities include introducing intrabar granularity for fill prices by either using the High Order Fill Resolution or adding a 1-tick data series programmatically and submitting orders to that series. I will provide relevant links about these options further below.

        You are not doing anything "wrong" with the market orders such as EnterLong() or ExitLong() either. With the standard historical fill algorithm, it is expected that when orders are filled they are filled at either the Open, High, Low, or Close price. Only OHLC prices are known with the standard fill algorithm. To get intrabar fill prices, you could need to use the High order fill resolution or program your strategy to submit orders to a single-tick data series. Please review the following links for more information:Thank you for your time and patience.

        Comment


          #5
          Ah, ok, it's all slowly sinking in. I added a 1 tick data series and place orders on that series index and now the orders are being placed where and when I expect.
          Thanks!

          Comment


            #6
            I'm currently backtesting a strategy that uses a tick data series and it still has this error where it says the order is ignored. I've looked at the userguide and there's no order state listed for ignoring the order when the stop being placed is above the current market price. In a live environment it will liquidate and shut the script off but in a historical backtest, even with the tick data series, we still are having issues with solving this issue.

            Comment


              #7
              Originally posted by Ymcapital View Post
              I'm currently backtesting a strategy that uses a tick data series and it still has this error where it says the order is ignored. I've looked at the userguide and there's no order state listed for ignoring the order when the stop being placed is above the current market price. In a live environment it will liquidate and shut the script off but in a historical backtest, even with the tick data series, we still are having issues with solving this issue.
              I have exactly the same problem. I cannot backtest even using High Order Fill Resolution (1min, 1 tick).

              Comment


                #8
                Hello adampl,

                Welcome to the NinjaTrader forums!

                Try implementing 1-tick intra-bar granularity as GregX999 has done.


                Let me know if this does not resolve the behavior.
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Today, 05:17 AM
                0 responses
                50 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                126 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                69 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                42 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                46 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X