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 CarlTrading, 03-31-2026, 09:41 PM
|
1 response
45 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
21 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
31 views
1 like
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
50 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
42 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment