Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CancelAllOrders

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

    CancelAllOrders

    If I have a unfilled stop order and a filled long position, to close everything should I use CancelAllOrders followed by ExitLong?

    and does CancelAllOrders raise an OnOrderUpdate event with order.OrderState == OrderState.Cancelled for each order cancelled?

    #2
    Hello delTik, and thank you for your question.

    If this is a NinjaTrader 7 question, the ATI method CancelAllOrders will not generate OnOrderUpdate events. You can safely use ExitLong() and ExitShort() whether you have open positions or not, with no arguments, to return to a flat position, provided you are not using signal names. ATI methods will all have to be checked on both sides of the ATI.

    If this is a NinjaTrader 8 question, we have prepared a short test, which shows CancelAllOrders() canceling several generated limit orders, and generating OnOrderUpdate events. We discovered putting this test together, however, that it is very easy to set an order to a pending cancel state, and to then modify it back with a price before it is successfully cancelled. Therefore, I would highly recommend, if you intend on relying on CancelAllOrders, that you include some position and state checking logic in your code similar to that in the sample I will provide.

    Please let us know if there is any other way we can help.
    Attached Files
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    144 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    298 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    242 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    339 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    172 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X