Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Perr0Grande, Today, 08:16 PM
      0 responses
      2 views
      0 likes
      Last Post Perr0Grande  
      Started by elderan, Today, 08:03 PM
      0 responses
      5 views
      0 likes
      Last Post elderan
      by elderan
       
      Started by algospoke, Today, 06:40 PM
      0 responses
      10 views
      0 likes
      Last Post algospoke  
      Started by maybeimnotrader, Today, 05:46 PM
      0 responses
      11 views
      0 likes
      Last Post maybeimnotrader  
      Started by quantismo, Today, 05:13 PM
      0 responses
      7 views
      0 likes
      Last Post quantismo  
      Working...
      X