Announcement

Collapse
No announcement yet.

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.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X