UPDATE: I found the strategy method CloseStrategy(string). Is this the method that I'm looking for? Will CloseStrategy(null) just close/cancel everything (which is what I want)?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Command to exit and close everything?
Collapse
X
-
Command to exit and close everything?
I am using a strategy that used the unmanaged approach to enter orders. Suppose I wish to immediately exit all orders at market and cancel all pending orders (eg stops and targets). Is there a simple command I can use to close/cancel everything? Yes I know that strategies do this automatically when RealtimeErrorHandling is StopCancelClose, but I want to trigger this in specific conditions inside my strategy.
UPDATE: I found the strategy method CloseStrategy(string). Is this the method that I'm looking for? Will CloseStrategy(null) just close/cancel everything (which is what I want)?Last edited by westofpluto; 08-11-2021, 08:05 AM.Tags: None
-
Hello westofpluto,
Thank you for the post.
The command which would do all of that will also disable the strategy, that is the CloseStrategy command:
The alternative would be to just use the order objects that you are tracking to cancel those orders. Any open positions could then be exited after confirming all targets were cancelled, you would generally do that part in OnOrderUpdate.
I look forward to being of further assistance.
-
Hi jess - yes disabling the strategy is fine, as long as it also closes everything. Like I said, I want to replicate the default behavior of what happens when we get a rejected order, which is to close all open positions, cancel any pending stops and targets. If CloseStrategy does this then that's what I want.
Comment
-
Hello westofpluto,
Thank you for the post.
Yes the method will do what you are asking, there is a sample and more information in the help guide page I had linked. Please ensure to read the help guide notes to make sure that works for your use case, otherwise you just need to manage the orders/position yourself in your logic.
Please let me know if I may be of further assistance.
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
by Mindset
04-21-2026, 06:46 AM
|
||
|
Started by M4ndoo, 04-20-2026, 05:21 PM
|
0 responses
135 views
0 likes
|
Last Post
by M4ndoo
04-20-2026, 05:21 PM
|
||
|
Started by M4ndoo, 04-19-2026, 05:54 PM
|
0 responses
68 views
0 likes
|
Last Post
by M4ndoo
04-19-2026, 05:54 PM
|
||
|
Started by cmoran13, 04-16-2026, 01:02 PM
|
0 responses
119 views
0 likes
|
Last Post
by cmoran13
04-16-2026, 01:02 PM
|
||
|
Started by PaulMohn, 04-10-2026, 11:11 AM
|
0 responses
69 views
0 likes
|
Last Post
by PaulMohn
04-10-2026, 11:11 AM
|

Comment