Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

order invalid based on price error

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

    order invalid based on price error

    I can create this error every single time.

    An order has been ignored since the stop price ... is invalid based on the price range of the bar.

    The stop prices have no relation to the data prices, the stop prices can be above or below the data prices.

    This code will create the error on ES data



    protected override void OnBarUpdate()
    {
    //Add your custom strategy logic here.

    /*
    This will reproduce the "order has been ignored since the stop price ‘xxxx’ near the bar stamped ‘01/01/2025 18:21:00’ is invalid" error

    These are the first 2 prices for this test on ES

    1/1/2025 6:21:00 PM 5950 , 5950 , 5947.75 , 5948.25
    1/1/2025 6:22:00 PM 5948.25 , 5949.5 , 5948 , 5949.5

    It occurs on the very first time the stop limit is executed.

    If the order is ShortStopLimit and the stop price greater than about 5760 the error occurs

    If the order is LongStopLimit and the stop price less than about 6160 the error occurs

    */

    if (CurrentBar < BarsRequiredToTrade)
    return;

    EnterLongStopLimit(2000 , 6160 );

    //EnterShortStopLimit(8000 , 5760 );

    if ( numPrinted++ < 2 )
    Print( Bars.GetTime(CurrentBar) + " " + Open[0] + " , " + High[0] + " , " + Low[0] + " , " + Close[0] );

    }

    Attached Files

    #2
    This should have been posted in the strategy development section, maybe someone can move it.

    Thanks,

    Gary

    Comment


      #3
      Hello garylyb,

      Ensure the buy stop price is above the current ask.

      See the support article below which provides sample code.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Please look again

        Here is the output from my 1 line script:

        The order is: EnterLongStopLimit(6000 , 6000 )

        The data values are : 1/1/2025 6:21:00 PM Open = 5950 High = 5950 Low = 5947.75 Close = 5948.25 Ask = 5950.5

        Strategy 'MyHGTest/-1': An order has been ignored since the stop price ‘6000’ near the bar stamped ‘01/06/2025 18:01:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.


        Clearly, 6000 is greater than any values in the data, and I get that error.

        Just run that 1 line on March ES starting at 1/1/2025.

        Here is the script:

        EnterLongStopLimit(6000 , 6000 );

        double ask = Bars.GetAsk(CurrentBar);

        if ( numPrinted++ < 1 )
        {
        Print ( " The order is: EnterLongStopLimit(6000 , 6000 ) " );
        Print ( " " );
        Print ( "The data values are : " + Bars.GetTime(CurrentBar) + " Open = " + Open[0] + " High = " + High[0] + " Low = " + Low[0] + " Close = " + Close[0] + " Ask = " + ask );
        Print ( " " );
        }

        Comment


          #5
          Hello garylyb,

          The data and the error have different dates and times.

          The data shows 1/1/2025 6:21:00.
          The error shows ‘01/06/2025 18:01:00.

          The ask was likely equal to or greater than 6000 on jan 6th at 6:01 pm.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            There is something screwy here, That gave me an error at 18:01, when the exchange re opened, but not at the many times before that whee the stop was below the ask.

            The error moves around

            for a price of 6000, the error occurs at 18:01, when the exchange opens. It does not occur on all the invalid data before that.

            The data values are : 1/6/2025 4:33:00 PM Open = 6025.75 High = 6026.5 Low = 6025.75 Close = 6026.5 Ask = 6026.25
            The data values are : 1/6/2025 4:34:00 PM Open = 6026.5 High = 6027 Low = 6026.25 Close = 6026.5 Ask = 6027
            The data values are : 1/6/2025 4:35:00 PM Open = 6026.5 High = 6026.5 Low = 6026.25 Close = 6026.5 Ask = 6027
            The data values are : 1/6/2025 4:36:00 PM Open = 6026.25 High = 6026.5 Low = 6026.25 Close = 6026.5 Ask = 6026.75
            The data values are : 1/6/2025 4:37:00 PM Open = 6026.25 High = 6026.5 Low = 6025.75 Close = 6025.75 Ask = 6026.5
            The data values are : 1/6/2025 4:38:00 PM Open = 6026 High = 6026 Low = 6025.5 Close = 6025.5 Ask = 6026.5
            The data values are : 1/6/2025 4:39:00 PM Open = 6025.75 High = 6026 Low = 6025.5 Close = 6025.75 Ask = 6026
            The data values are : 1/6/2025 4:40:00 PM Open = 6025.5 High = 6026 Low = 6025.25 Close = 6025.75 Ask = 6025.75
            The data values are : 1/6/2025 4:41:00 PM Open = 6026 High = 6026 Low = 6025.5 Close = 6025.75 Ask = 6026.25
            The data values are : 1/6/2025 4:42:00 PM Open = 6025.75 High = 6025.75 Low = 6025.5 Close = 6025.5 Ask = 6026.25
            The data values are : 1/6/2025 4:43:00 PM Open = 6025.5 High = 6026 Low = 6025.5 Close = 6025.75 Ask = 6025.75
            The data values are : 1/6/2025 4:44:00 PM Open = 6025.75 High = 6026 Low = 6025.5 Close = 6025.5 Ask = 6026.25
            The data values are : 1/6/2025 4:45:00 PM Open = 6025.5 High = 6026 Low = 6025.5 Close = 6026 Ask = 6026
            The data values are : 1/6/2025 4:46:00 PM Open = 6026 High = 6026 Low = 6025.25 Close = 6026 Ask = 6026.5
            The data values are : 1/6/2025 4:47:00 PM Open = 6026.25 High = 6026.5 Low = 6026.25 Close = 6026.25 Ask = 6026.75
            The data values are : 1/6/2025 4:48:00 PM Open = 6026.5 High = 6027.5 Low = 6026.25 Close = 6027.5 Ask = 6027
            The data values are : 1/6/2025 4:49:00 PM Open = 6027.5 High = 6028 Low = 6027.5 Close = 6027.5 Ask = 6027.75
            The data values are : 1/6/2025 4:50:00 PM Open = 6027.75 High = 6028 Low = 6027 Close = 6027.75 Ask = 6028.25
            The data values are : 1/6/2025 4:51:00 PM Open = 6028 High = 6028 Low = 6027.75 Close = 6027.75 Ask = 6028.5
            The data values are : 1/6/2025 4:52:00 PM Open = 6028 High = 6028.25 Low = 6028 Close = 6028 Ask = 6028.5
            The data values are : 1/6/2025 4:53:00 PM Open = 6028.25 High = 6028.5 Low = 6028.25 Close = 6028.25 Ask = 6028.75
            The data values are : 1/6/2025 4:54:00 PM Open = 6028.5 High = 6028.5 Low = 6027.75 Close = 6028 Ask = 6029
            The data values are : 1/6/2025 4:55:00 PM Open = 6028 High = 6028.25 Low = 6027.75 Close = 6028 Ask = 6028.5
            The data values are : 1/6/2025 4:56:00 PM Open = 6028 High = 6028.5 Low = 6028 Close = 6028.25 Ask = 6028.5
            The data values are : 1/6/2025 4:57:00 PM Open = 6028 High = 6028.25 Low = 6027.25 Close = 6027.5 Ask = 6028.25
            The data values are : 1/6/2025 4:58:00 PM Open = 6027.5 High = 6027.75 Low = 6027.25 Close = 6027.5 Ask = 6027.75
            The data values are : 1/6/2025 4:59:00 PM Open = 6027.5 High = 6027.75 Low = 6027 Close = 6027 Ask = 6028
            The data values are : 1/6/2025 5:00:00 PM Open = 6027 High = 6028.5 Low = 6027 Close = 6028.25 Ask = 6027.5
            Strategy 'MyHGTest/-1': An order has been ignored since the stop price ‘6000’ near the bar stamped ‘01/06/2025 18:01:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.
            The data values are : 1/6/2025 6:01:00 PM Open = 6028 High = 6029.5 Low = 6027.5 Close = 6028.75 Ask = 6028.5
            The data values are : 1/6/2025 6:02:00 PM Open = 6029 High = 6031.75 Low = 6028.75 Close = 6031.5 Ask = 6029.5
            The data values are : 1/6/2025 6:03:00 PM Open = 6031.5 High = 6031.75 Low = 6031 Close = 6031.75 Ask = 6032
            The data values are : 1/6/2025 6:04:00 PM Open = 6031.75 High = 6031.75 Low = 6031.25 Close = 6031.5 Ask = 6032.25
            The data values are : 1/6/2025 6:05:00 PM Open = 6031.5 High = 6031.75 Low = 6031 Close = 6031.75 Ask = 6032
            The data values are : 1/6/2025 6:06:00 PM Open = 6031.25 High = 6031.75 Low = 6030.25 Close = 6030.25 Ask = 6031.75
            The data values are : 1/6/2025 6:07:00 PM Open = 6030.5 High = 6030.5 Low = 6029.75 Close = 6030 Ask = 6031
            The data values are : 1/6/2025 6:08:00 PM Open = 6030 High = 6030.5 Low = 6030 Close = 6030.5 Ask = 6030.5
            The data values are : 1/6/2025 6:09:00 PM Open = 6030.25 High = 6030.25 Low = 6029.5 Close = 6029.5 Ask = 6030.75
            The data values are : 1/6/2025 6:10:00 PM Open = 6029.75 High = 6029.75 Low = 6029 Close = 6029.5 Ask = 6030.25
            The data values are : 1/6/2025 6:11:00 PM Open = 6029.5 High = 6030 Low = 6029.5 Close = 6030 Ask = 6030
            The data values are : 1/6/2025 6:12:00 PM Open = 6030 High = 6030.5 Low = 6029.75 Close = 6030 Ask = 6030.5
            The data values are : 1/6/2025 6:13:00 PM Open = 6030.25 High = 6030.25 Low = 6029.75 Close = 6030 Ask = 6030.75
            The data values are : 1/6/2025 6:14:00 PM Open = 6029.75 High = 6030.25 Low = 6029.75 Close = 6030 Ask = 6030.25
            The data values are : 1/6/2025 6:15:00 PM Open = 6030 High = 6030 Low = 6029.5 Close = 6029.75 Ask = 6030.5
            The data values are : 1/6/2025 6:16:00 PM Open = 6029.5 High = 6029.5 Low = 6029.25 Close = 6029.25 Ask = 6030
            The data values are : 1/6/2025 6:17:00 PM Open = 6029.25 High = 6029.5 Low = 6028.75 Close = 6029 Ask = 6029.75
            The data values are : 1/6/2025 6:18:00 PM Open = 6029 High = 6029 Low = 6028.25 Close = 6028.5 Ask = 6029.5
            The data values are : 1/6/2025 6:19:00 PM Open = 6028.25 High = 6028.5 Low = 6028.25 Close = 6028.5 Ask = 6028.75
            The data values are : 1/6/2025 6:20:00 PM Open = 6028.5 High = 6028.75 Low = 6028 Close = 6028 Ask = 6029
            The data values are : 1/6/2025 6:21:00 PM Open = 6028 High = 6028 Low = 6026.25 Close = 6027.75 Ask = 6028.5
            The data values are : 1/6/2025 6:22:00 PM Open = 6027.75 High = 6028 Low = 6026.25 Close = 6027 Ask = 6028.25
            The data values are : 1/6/2025 6:23:00 PM Open = 6027 High = 6027.5 Low = 6026.75 Close = 6027.5 Ask = 6027.5
            The data values are : 1/6/2025 6:24:00 PM Open = 6027.5 High = 6027.75 Low = 6027.25 Close = 6027.5 Ask = 6028
            The data values are : 1/6/2025 6:25:00 PM Open = 6027.5 High = 6027.75 Low = 6027.25 Close = 6027.25 Ask = 6028
            The data values are : 1/6/2025 6:26:00 PM Open = 6027.5 High = 6028 Low = 6027.25 Close = 6028 Ask = 6027.75
            The data values are : 1/6/2025 6:27:00 PM Open = 6027.75 High = 6028.5 Low = 6027.75 Close = 6028.25 Ask = 6028.25
            The data values are : 1/6/2025 6:28:00 PM Open = 6028.25 High = 6028.5 Low = 6028 Close = 6028.25 Ask = 6028.75

            Comment


              #7
              Hello garylyb,

              Likely the order has been ignored further in the past. The messages are suppressed after they appear once in a session to keep from spamming the output window.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                I got the error here when the stop is above the ask, and below the close, if the ask was the problem this should work:

                The data values are : 1/2/2025 10:05:00 AM Open = 5972.25 High = 5979.25 Low = 5971.75 Close = 5978.75 Ask = 5972.75
                1/2/2025 10:05:00 AM new stopprice = 5978.16 ask = 5972.75 Diff = 5.40999999999985

                Strategy 'MyESStrategy/-1': An order has been ignored since the stop price ‘5978.25’ near the bar stamped ‘01/02/2025 10:05:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.

                Basically, I don't get the error when I should, and get when I shouldn't get it. There is something going on, I don't know what. It does not seem consistent.

                Comment


                  #9
                  There are no error messages before that ones i sent you,

                  Comment


                    #10
                    I get some errors where the stop is above the ask, but below the high. If I increase the stop price it goes away.

                    new stopprice is the value that gets sent in the instruction.

                    1/2/2025 9:43:00 AM stopprice = 5939.55 ask = 5939.5
                    The data values are : 1/2/2025 9:43:00 AM Open = 5939.5 High = 5944 Low = 5934.75 Close = 5941.75 Ask = 5939.5

                    1/2/2025 9:43:00 AM new stopprice = 5941 ask = 5939.5 Diff = 0.0500000000001819

                    Strategy 'MyESStrategy/-1': An order has been ignored since the stop price ‘5941’ near the bar stamped ‘01/02/2025 09:43:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.


                    The data values are : 1/2/2025 10:05:00 AM Open = 5972.25 High = 5979.25 Low = 5971.75 Close = 5978.75 Ask = 5972.75

                    1/2/2025 10:05:00 AM new stopprice = 5978.16 ask = 5972.75 Diff = 5.40999999999985

                    Strategy 'MyESStrategy/-1': An order has been ignored since the stop price ‘5978.25’ near the bar stamped ‘01/02/2025 10:05:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.

                    something is going on. seems kind of random.

                    Comment


                      #11
                      Just ran this test and got the error

                      double ask = Bars.GetAsk(CurrentBar);
                      double stopprice = ( High[0] + ask ) / 2;
                      EnterLongStopLimit(stopprice, stopprice);

                      Strategy 'MyHGTest/-1': An order has been ignored since the stop price ‘5889’ near the bar stamped ‘01/13/2025 18:01:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.

                      The data values are : 1/13/2025 6:01:00 PM Open = 5887.25 High = 5890.25 Low = 5886.75 Close = 5890 Ask = 5887.75

                      If you need anything else let me know,

                      If the stop is above the high, there are no errors.

                      Comment


                        #12
                        Hello garylyb,

                        I've made a test script that tests submitting an EnterLongStopLimit() with the stop price above the ask price.
                        GarylybLongStopLimitTest_NT8.zip
                        NinjaScript Output 3_11_2025 5_53 AM.txt

                        I am not able to reproduce the ignored order.

                        Without making modifications, are you able to reproduce the ignored order?

                        If so, save the output from the output window to a text file (right-click the output window, select Save as).
                        Attach the output text file to your next post.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Here is the output from your script.

                          I still get this error running this line

                          stopprice = ( High[0] + ask ) /2;


                          Strategy 'MyHGTest/-1': An order has been ignored since the stop price ‘5889’ near the bar stamped ‘01/13/2025 18:01:00’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.

                          The data values are : 1/13/2025 6:01:00 PM Open = 5887.25 High = 5890.25 Low = 5886.75 Close = 5890 Ask = 5887.75 Bid = 5887.25
                          Attached Files

                          Comment


                            #14
                            Hello garylyb,

                            To confirm the ignored order warning is not occurring without modifying the script?

                            Which line specifically did you modify?

                            The output you provided is not from the script I have provided you.
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Here it is, i have too many files.

                              I don't remember exactly, I just added a line before the enter statement and set stop and limit to average of high and ask.
                              Attached Files

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by argusthome, 03-08-2026, 10:06 AM
                              0 responses
                              57 views
                              0 likes
                              Last Post argusthome  
                              Started by NabilKhattabi, 03-06-2026, 11:18 AM
                              0 responses
                              37 views
                              0 likes
                              Last Post NabilKhattabi  
                              Started by Deep42, 03-06-2026, 12:28 AM
                              0 responses
                              18 views
                              0 likes
                              Last Post Deep42
                              by Deep42
                               
                              Started by TheRealMorford, 03-05-2026, 06:15 PM
                              0 responses
                              20 views
                              0 likes
                              Last Post TheRealMorford  
                              Started by Mindset, 02-28-2026, 06:16 AM
                              0 responses
                              49 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Working...
                              X