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, 05-11-2026, 05:56 AM
    0 responses
    56 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    33 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    195 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    359 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    280 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X