Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel Limit order that passed the stop price

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

    Cancel Limit order that passed the stop price

    Hi support,

    I have a situation as the followed. I have SetStoploss() and EnterLongLimit(), but the next candle gapped down beyond my stoploss. When this happens, I would like to cancel the order. How can I detect that the price gapped down beyond my stoploss?

    Thank you

    #2
    Hi op1031,
    You could compare the close of the previous bar with the open of the current bar. A "gap" is present, if the close of the previous bar is above, but the open of current bar is below your stoploss. Perhaps add some logic to determine that the gap must exceed a certain minimum size to qualify as such before cancelling your EnterLongLimit order?
    NT-Roland
    Last edited by NT-Roland; 05-09-2021, 09:04 AM.

    Comment


      #3
      Hello op1031,

      When using set methods you can get the stop price of the stop loss.

      Below is a link to a forum post with sample code.
      https://ninjatrader.com/support/foru...092#post786092

      The Close[0] price could be compared to this in OnBarUpdate, or the marketDataArgument in OnMarketData.

      The issue would be with cancelling an order. Set method orders cannot be cancelled or unset.

      I would recommend instead using exit orders or the unmanaged approach as these orders can be cancelled with CancelOrder().
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 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
      30 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
      40 views
      0 likes
      Last Post CarlTrading  
      Working...
      X