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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    88 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    134 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    119 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    69 views
    0 likes
    Last Post PaulMohn  
    Working...
    X