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

Stop order can't be placed above the bid

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

    Stop order can't be placed above the bid

    In set 6 I set the StopPrice -1 tick behind the bid. Should I make it -2 ticks or is there more I can do?

    This just occurred.
    Attached Files

    #2
    Hello trdninstyle,

    Thanks for your post.

    This error message means that the strategy attempted to place an order on the wrong side of the market. Buy stop orders must be placed above the current ask price. Sell stop orders must be placed below the current bid price.

    If this is due to market volatility then there isn't really a way to 100% avoid this occurring, as in volatile markets the market could move so far and fast that this would occur.

    You could consider placing your stop loss further from the current price to correct this error.

    I would recommend you add prints to the strategy to determine why the stop order is being rejected. Prints should be added to the script that print out the value you are submitting your stop loss order to and prints out the current market price (Close[0]). This will allow you to see where the order is trying to be placed in comparison with the current market price.

    Below is a link to a forum post that demonstrates using prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121

    Something else you could consider is changing the strategy to use StopCancelCloseIgnoreErrors for its error handling. You could then capture the rejection in OnOrderUpdate, and then either try to resubmit the stop at a different price or submit an exit order to close the position. Note that this would require unlocking the strategy from the Strategy Builder and manually programming your logic.

    You can find more information about real-time error handling for strategies here, along with an example of capturing the rejection:
    https://ninjatrader.com/support/help...orhandling.htm

    Let us know if we may assist further.​​
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Hello BrandonH,

      'Changing the strategy to use StopCancelCloseIgnoreErrors for its error handling. You could then capture the rejection in OnOrderUpdate, and then either try to resubmit the stop at a different price or submit an exit order to close the position.'

      This sounds very interesting, plus what u said about the market when it's volatile that it just happens. Then I would just reset it. The other day it went the entire day without that happening so it could be that it was too volatile. But what if I set the bid at -2 tick size instead of -1 tick size. Could that have any bearing?

      Thanks for your tip. Bill

      Comment


        #4
        Hello Bill,

        Thanks for your note.

        Increasing the stop loss by one extra tick would place the stop loss 1 more tick away the price that it is currently being submitted to.

        Ultimately, you would need to test your strategy to determine if that one extra tick will keep the order rejection error from occurring. If the order rejection error continues to occur when testing, you may need to place your stop order further from the current price.

        Further, prints should be added to the script that prints out the value you are submitting your stop loss order to and prints out the current market price (Close[0]). This will allow you to see where the order is trying to be placed in comparison with the current market price. Then you could modify your stop loss accordingly.

        Below is a link to a forum post that demonstrates using prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121

        Let me know if I may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          I mean this thing, that ensures for the most part my stop stays 1 tick below the bid. Not the actual stop loss. If I set a further stop for all the time it will get hit on those reversals.
          The opposite direction entry will cancel out my stop for the upside and vice versa.

          So, what I meant was, for the -1 tick behind the bid, could I make it -2 or a higher #?

          StopPrice = (GetCurrentBid(default input) + (-1 *TickSize));

          BTY have a good holiday tomorrow. If it's late get back to me on Friday or Monday.
          Attached Files
          Last edited by trdninstyle; 11-23-2022, 03:21 PM.

          Comment


            #6
            Hello trdninstyle,

            Thanks for your note.

            Yes, that is correct. You could set the StopPrice to use the Bid price minus 2 ticks or more to meet your goal.

            Note that in volatile markets the market could move so far and fast that this error could still occur so you would need to test your strategy to ensure it behaves as you want it to.

            I hope you have a good holiday too. Please let me know if you have further questions.

            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              Okay that what I'll do, it's good to know that I can do that. I don't want to try something without knowing for sure if thats what it's meant to do.

              You too buddy. Have a good one. Thanks.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by AaronKoRn, Yesterday, 09:49 PM
              0 responses
              11 views
              0 likes
              Last Post AaronKoRn  
              Started by carnitron, Yesterday, 08:42 PM
              0 responses
              10 views
              0 likes
              Last Post carnitron  
              Started by strategist007, Yesterday, 07:51 PM
              0 responses
              11 views
              0 likes
              Last Post strategist007  
              Started by StockTrader88, 03-06-2021, 08:58 AM
              44 responses
              3,981 views
              3 likes
              Last Post jhudas88  
              Started by rbeckmann05, Yesterday, 06:48 PM
              0 responses
              9 views
              0 likes
              Last Post rbeckmann05  
              Working...
              X