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 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
      67 views
      0 likes
      Last Post PaulMohn  
      Working...
      X