Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel order before bar close

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

    Cancel order before bar close

    Hi,

    I´m programming a breakout strategy with CalculateOnBarClose = true. But in some moments i need to send a EnterLongStop and a EnterShortStop order at a same bar. After that, i wait a execution of one. When one order are filled, the strategy need to cancel the other.

    However, just will known about the execution of the first order in the next bar.

    How can i cancel the second order before the end of the bar?

    Thanks for any help,
    PH

    #2
    Hello pedrokramer,

    Thank you for your post and welcome to our forums!

    You can use event driven methods such as OnExecution() to cancel the opposite order using CancelOrder()

    Please see our Reference Sample on using CancelOrder() and OnExecution() method:

    When using NinjaTrader's Enter() and Exit() methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    646 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    367 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    569 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X