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 affect order" killing my strategy?

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

    "stop price can't be changed below the market affect order" killing my strategy?


    Hi there, how do I prevent the "stop price can't be changed below the market affect order" error from killing my strategy?

    I've read the other forum posts on the cause of this error, that it's due to market volatility and can't be 100% avoided. I can live with that, but every time I get this error, it then kills my running strategy. Furthermore, any data in the Unrealized / Realized column is now lost, so I can't evaluate the strategy either. Lastly, I do have "IgnoreAllErrors" turned on.

    How can I prevent this annoying error from taking down a running strategy? Thanks,





    #2
    Hello timmbbo,

    Thank you for your post.

    This error message means that the strategy attempted to change an order to the wrong side of the market. First, please make sure that it is in fact due to market volatility (in that case, there would be no way to avoid the error occurring).

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

    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.

    You can do this by checking if the current bid is greater than or less than the price you are submitting the order to.

    GetCurrentBid - https://ninjatrader.com/support/help...currentbid.htm


    Code:
    if (GetCurrentBid() > Position.AveragePrice)
    
    SetStopLoss(CalculationMode.Price, Position.AveragePrice);

    Please note that if you are using SetStopLoss(), you may also need to reset the set method using CalculationMode.Ticks before placing a new entry. For an example of how to do this, please see the linked example code.


    Modifying the price of stop loss and profit target orders -

    https://ninjatrader.com/support/help...of_stop_lo.htm


    If you have IgnoreAllErrors enabled, make sure you have added the logic to trap this specific error in OnOrderUpdate by checking error == ErrorCode.UnableToChangeOrder.

    Realtime Error Handling - https://ninjatrader.com/es/support/h...orhandling.htm

    OnOrderUpdate - https://ninjatrader.com/es/support/h...rderupdate.htm

    Please let us know if you have any other questions.
    Gaby V.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by TraderJA, Today, 12:06 AM
    0 responses
    3 views
    0 likes
    Last Post TraderJA  
    Started by SnailHorn, Yesterday, 10:49 PM
    0 responses
    7 views
    0 likes
    Last Post SnailHorn  
    Started by naanku, Yesterday, 07:25 PM
    0 responses
    8 views
    0 likes
    Last Post naanku
    by naanku
     
    Started by milfocs, Yesterday, 07:23 PM
    0 responses
    6 views
    0 likes
    Last Post milfocs
    by milfocs
     
    Started by PaulMohn, Yesterday, 06:59 PM
    0 responses
    8 views
    0 likes
    Last Post PaulMohn  
    Working...
    X