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 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