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
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!
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
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.JesseNinjaTrader Customer Service
-
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.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by burtoninlondon, Today, 12:38 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 12:38 AM | ||
Started by AaronKoRn, Yesterday, 09:49 PM
|
0 responses
13 views
0 likes
|
Last Post
by AaronKoRn
Yesterday, 09:49 PM
|
||
Started by carnitron, Yesterday, 08:42 PM
|
0 responses
11 views
0 likes
|
Last Post
by carnitron
Yesterday, 08:42 PM
|
||
Started by strategist007, Yesterday, 07:51 PM
|
0 responses
13 views
0 likes
|
Last Post Yesterday, 07:51 PM | ||
Started by StockTrader88, 03-06-2021, 08:58 AM
|
44 responses
3,982 views
3 likes
|
Last Post
by jhudas88
Yesterday, 06:59 PM
|
Comment