Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price falls through stop loss without triggering

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

    Price falls through stop loss without triggering

    I think there is a rare condition where the strategy looks as though it has a protective stop, but price (say for a Long position) price has fallen below the Stop without triggering a sell.
    This might be no fault of NT but due to a race condition in the Broker's application.
    Brokers usually have some small print saying they don't guarantee that Stops will trigger.

    Take Josh's sample code for raising a stop on a long position to break even after a certain profit. http://www.ninjatrader.com/support/f...ead.php?t=3225

    When this line executes
    SetStopLoss(CalculationMode.Price, Position.AvgPrice)
    I assume the original stop loss order is cancelled, then a new one is pending at entry price. But suppose the price now falls rapidly to below entry price (and carries on falling) before the new Stop becomes active at the broker/exchange. The position is now unprotected.

    Question 1: Is there a recommended way to get out of this situation?
    I assume the strategy could check for Close[0] < mylastStopPrice (for longer than a certain period) and attempt to retrieve the situation by either:
    1) set mylastStopPrice to below current price and use
    SetStopLoss(CalculationMode.Price, mylastStopPrice )
    and hope the broker deals with it normally this time.
    or
    2) just use ExitLong(), which I hope would also cancel the untriggered stop as normal.

    Obviously its hard to test such code. So just want to make sure my attempt to compensate would not conflict with something the NT order management may be doing in these rare conditions.

    Question 2: Does NT order management try to compensate itself in this situation?
    If so I guess I should avoid trying to code for it.

    #2
    DaveE, it would be best to work with TraceOrders in your strategy to debug it's under the hood order behavior - http://www.ninjatrader.com/support/f...ead.php?t=3627

    The stop loss would not be cancelled, but resubmitted at a new price, thus the position is not unprotected.

    Comment


      #3
      Bertrand,

      Thanks for the quick reply.
      OK so the stop is not "cancelled" but "resubmitted" so in theory the order is always protected as far as NT is concerned. But there is still the possibility of the new stop failing to trigger at the broker. So its left floating useless way above the descending price, in which case the position is unprotected.
      I will use TraceOrders, but since this is a rare situation its likely that results would be lost in the mass of information about stop orders that DID work as normal.
      So any chance of answering my two questions?

      Comment


        #4
        Dave, the more often you change the stop (orders in general) there's for sure the possibility that you would experience race conditions or in flight executions - this is just a fact in electronic trading. NinjaTrader works directly with the orderstates the broker / API would submit to us - http://www.ninjatrader-support.com/H...AppendixA.html

        If you happen to get a rejected stop order (for example because the submitted price was invalid) the strategy would be terminated - this can overridden if you're an advanced programmer and would like to code your own rejection handling - http://www.ninjatrader-support.com/H...rHandling.html

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        656 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        371 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        579 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X