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().
      https://ninjatrader.com/support/foru...269#post802269
      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by timmbbo, Yesterday, 10:27 PM
      1 response
      5 views
      0 likes
      Last Post tgn55
      by tgn55
       
      Started by zacharydw00, Yesterday, 11:13 PM
      0 responses
      2 views
      0 likes
      Last Post zacharydw00  
      Started by luxurious_04, Yesterday, 10:55 PM
      0 responses
      1 view
      0 likes
      Last Post luxurious_04  
      Started by 7robert, Yesterday, 07:48 PM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by saltminer, Yesterday, 06:32 PM
      0 responses
      6 views
      0 likes
      Last Post saltminer  
      Working...
      X