Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error Handling Stop Loss above price in long

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

    Error Handling Stop Loss above price in long

    So I followed the instructions on Ninjatraders website about order handling. I have stop losses that move close to the current price, but sometimes the price quickly goes back down and it thinks it's trying to place a stop above the price, so it freaks out and closes out.


    In order to handle this error, I am utilizing this code as instructed in ninja traders guide in the link above:

    This is inside onStateChange():
    if(State == State.Configure)
    {
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelCloseIgnoreRejects ; //to stop the strategy from closing itself
    }


    This is inside onOrderUpdate():
    if(order_One.OrderState == OrderState.Rejected || order_Two.OrderState == OrderState.Rejected)
    {
    SetStopLoss("One", CalculationMode.Ticks, (beOffset * -1) - 10 * TickSize, false); //this time try to move the stop 10 ticks lower than where you tried the first time and got rejected
    }

    My problem is that for some reason, when I check "enable strategy", it immediately turns back off and nothing happens. BUT if I comment out the section of code inside of onOrderChange() Then it loads just fine.

    Someone, please help me do this order handling thing correctly.

    #2
    Hello digo098,

    Can you print (beOffset * -1) - 10 * TickSize.

    Somehow I think this might be a negative value.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    169 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    88 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    128 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    208 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    185 views
    0 likes
    Last Post CarlTrading  
    Working...
    X