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 Price can't be changed below the market question

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

    Stop Price can't be changed below the market question

    So im paper trading at the moment and I'm getting this error.
    Click image for larger version

Name:	image.png
Views:	353
Size:	17.7 KB
ID:	1227623

    1. My first question is could you explain why this is happening? After reading some old posts, I get the jist but not the full picture clearly.

    2. Looking at this older post, and to explain how my strategy works is that I set stop losses whenever the current swing high or swing low is higher or lower than the previous swing high/low. Is what Jesse said in the old post that I cant use old Highs and Lows to set stop losses? If so what can I do to workaround it since my strategy relies on using previous highs and lows to set stop losses.
    Click image for larger version

Name:	image.png
Views:	300
Size:	47.4 KB
ID:	1227624
    https://ninjatrader.com/support/forum/forum/ninjatrader-8/strategy-development/1164616-buy-to-cover-stop-market-order-below-current-price ​


    Thanks!

    #2
    Click image for larger version

Name:	image.png
Views:	285
Size:	18.9 KB
ID:	1227626
    More examples​

    Comment


      #3
      tchen7 You may already know this, but just in case, there are some unbreakable rules regarding submitting Orders at specific prices vs current market Ask and Bid prices:
      • Order types that MUST be GREATER than the current ASK price: Sell Limit, Sell MIT, Buy StopMarket
      • Order types that MUST be LESS than the current BID price: Buy Limit, Buy MIT, Sell StopMarket
      No matter how an Order is submitted, it must satisfy these rules. This includes any price changes to existing Orders of these types.

      Hope that is useful.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #4
        Hello tchen7,

        Thanks for your note.

        This error message means that the strategy attempted to change an order to the wrong side of the market. 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.

        jeronymite is correct. Buy stop market orders must be placed above the current Ask price. Sell stop market orders must be placed below the current Bid price.

        As stated by my colleague Jesse in the forum post you shared, you must make sure that the price you are submitting or changing the order to is a valid price and on the correct side of the market. This could be done by checking if the current market price (Close[0]) is greater than or less than the price you are submitting the order to.

        You could also consider using RealtimeErrorHandling.IgnoreAllErrors to trap order errors in OnOrderUpdate by checking error == ErrorCode.UnableToChangeOrder.

        Please note that setting this property value to IgnoreAllErrors can have serious adverse affects on a running strategy unless you have programmed your own order rejection handling in the OnOrderUpdate() method. To do this you could trap the rejected order by checking if the OrderState is Rejected within OnOrderUpdate() followed by defining your own order rejection handling behavior for the rejected order.

        Please see the example in the help guide link below that demonstrates using RealtimeErrorHandling and trapping a rejected order in OnOrderUpdate().

        RealtimeErrorHandling — https://ninjatrader.com/es/support/h...orhandling.htm

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

        Comment


          #5
          Hello NinjaTrader_BrandonH ,

          Just to clarify, you can set Error Handling to RealtimeErrorHandling.StopCancelCloseIgnoreRejects . That will close the strategy on all other errors than rejected orders, correct? So, you retain most of the safety of the built in error handling. You just have handle rejected orders.

          Given that (assuming that's correct), is the error, ErrorCode.UnableToChangeOrder, considered an order rejection?

          Thanks,
          Matt

          PS: Thank you, jeronymite, for the succinct summary of order submission when near/at current price.

          Comment


            #6
            Hello StealthM93,

            Thanks for your note.

            Yes, RealtimeErrorHandling.StopCancelCloseIgnoreRejects will stop the strategy, cancel any remaining working orders, and then close any open positions managed by the strategy unless the error is an order rejection error. If the error is an order rejection, the strategy will resume running.

            That is correct. If you run the strategy with RealtimeErrorHandling.StopCancelCloseIgnoreRejects and you get the UnableToChangeOrder error message, the strategy will continue running.

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

            Comment


              #7
              Thank you for confirming, BrandonH!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by halgo_boulder, 04-20-2024, 08:44 AM
              2 responses
              21 views
              0 likes
              Last Post halgo_boulder  
              Started by mishhh, 05-25-2010, 08:54 AM
              19 responses
              6,189 views
              0 likes
              Last Post rene69851  
              Started by gwenael, Today, 09:29 AM
              0 responses
              5 views
              0 likes
              Last Post gwenael
              by gwenael
               
              Started by Karado58, 11-26-2012, 02:57 PM
              8 responses
              14,830 views
              0 likes
              Last Post Option Whisperer  
              Started by Option Whisperer, Today, 09:05 AM
              0 responses
              2 views
              0 likes
              Last Post Option Whisperer  
              Working...
              X