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

Error: Buy stop or buy stop limit orders can't be placed below the market.

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

    Error: Buy stop or buy stop limit orders can't be placed below the market.

    Hi NinjaTrader Support,

    when I test my strategy I get the following error message, as shown in the picture.

    Error: Buy stop or buy stop limit orders can't be placed below the market. affected Order: Buy 1 StopMarket.

    This problem occurs only with fast momentum movements or gaps in the market.

    My question is how can I solve this problem or which Ninjatrader method is necessary to do so?

    Do I need the protected override void OnExecutionUpdate() method?

    Best regards
    Tradeer

    #2
    Hello Tradeer,

    Thanks for your post.

    In your strategy logic you would need to check that the order you are about to place is appropriate for the current price of the instrument. You would need to run your strategy using Calculate.OnEachTick or Calculate.OnPriceChange as this will give the the current real time price (Close[0]). For you understanding if you are using calculate.OnBarClose, Close[0] would be the close price of the just closed bar not the current live price.

    In the specific example, the pop-up is advising that your strategy submitted a BuyStopMarket at 23903 that was Below the current market price when the order was placed.


    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      thanks for your quick reply!

      I'm using the CurrentAsk on Calculate.OnEachTick for the entry on Market Replay Data.

      But if the market moves too fast the orders are not placed fast enough.

      Most of the time it works correctly.




      This is the entry signal:


      if (GetCurrentAsk(0) == VAT)
      {
      EnterLongStopMarket(GetCurrentAsk(), "");
      }


      How can it be fixed that the order is placed correctly at the current price and not below or above the market?


      I have attached the indiactor and the strategy if you want to have a look at it.


      Last edited by Tradeer; 05-07-2020, 03:20 AM.

      Comment


        #4
        Hello Tradeer,

        Thanks for your reply.

        You are correct in the approach of using Calculate.OnEachTick.

        You are submitting a limit type order very close to the market price. The likely issue for you then is the internet time it takes for your PC to transmit the order to the exchange.

        Options are:

        1) To not submit the order so close to the current price.
        2) Submit as a market order
        3) Invest in a server that is physically located at the exchange itself to reduce the time it takes to submit an order.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi paul,

          thanks for your reply,

          1) how can i execute the order without error message.
          for example: the entry should be 1 tick later if the spread of the market is too wide.
          How do I implement this into the ninjascript code

          2) It' already a market order

          3) Maybe someday

          The file contains your script that you published Profittargettrailingstop_101B it's great!
          i have implemented it in the strategy.
          Big Credits it helped me a lot.

          Comment


            #6
            Hello Tradeer,

            Thanks for your reply.

            If you are going to use limit type orders you will have to test under the various market conditions to find what works. To clarify EnterLongStopMarket and EnterShortStopMarket methods are not market orders, they are set at a specific price and if the price is hit then they are submitted as market orders. The issue is submitting this type order too close to the market price when the volatility move the price above/below what is acceptable for submitting that type of order. A market order method is EnterLong or EnterShort that does not require a price level and would not generate any error messages.

            Thanks for the credit but I did not create the strategy, I only converted it from NinjaTrader7. Glad to hear it was helpful to you.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hi Paul,

              Thanks for your reply.

              Ah okay I understand that. I have also tried the EnterLong method before but the same issue.

              if (GetCurrentAsk(0) == VAT)
              {
              EnterLong(Convert.ToInt32(DefaultQuantity), "");
              // EnterLongStopMarket(GetCurrentAsk(), "");
              }

              Any idea how I can change it?
              Attached Files

              Comment


                #8
                Hello Tradeer,

                Thanks for your reply.

                The EnterLong() or EnterShort() would not create the the error message as these are market orders and they fill at the convenience of the market.

                The error messages are more likely associated with your stoploss orders.

                You will need to go through a debugging process to find at what point the orders are being submitted/adjusted incorrectly.

                Here is a link to our debugging tips to get you started: https://ninjatrader.com/support/help...script_cod.htm
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks Paul I'll test it.

                  Comment


                    #10
                    Hello,
                    I'm also running into similar issues. I'm already checking for valid prices but even that can result in those errors, especially when I'm working with brick style bars.
                    My question would be, is it somehow possible to catch this error? Even when this order is invalid, I would like in such cases to simply ignore the error and let the strategy continue running as it currently terminates when this happens.
                    Putting try catch around the enter methods does not catch this error. So what would be the appropriate way of handling this error be?

                    Comment


                      #11
                      Hello Human#102,

                      Thank you for your inquiry.

                      You can change the RealtimeErrorHandling of the strategy to .IgnoreAllErrors or .StopCancelCloseIgnoreRejects.

                      Please see the Help Guide page below which has code demonstrating:



                      You could then add logic in OnOrderUpdate() for how your strategy should handle any rejections.

                      If you have any further questions, please let me know.
                      Gaby V.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Barry Milan, Yesterday, 10:35 PM
                      3 responses
                      10 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Started by WeyldFalcon, 12-10-2020, 06:48 PM
                      14 responses
                      1,428 views
                      0 likes
                      Last Post Handclap0241  
                      Started by DJ888, 04-16-2024, 06:09 PM
                      2 responses
                      9 views
                      0 likes
                      Last Post DJ888
                      by DJ888
                       
                      Started by jeronymite, 04-12-2024, 04:26 PM
                      3 responses
                      41 views
                      0 likes
                      Last Post jeronymite  
                      Started by bill2023, Yesterday, 08:51 AM
                      2 responses
                      16 views
                      0 likes
                      Last Post bill2023  
                      Working...
                      X