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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    45 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    31 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X