Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Closing Strategy Positions/Working Orders Without Disabling Strategy
Collapse
X
-
Closing Strategy Positions/Working Orders Without Disabling Strategy
I have a strategy that enters orders and places take profit and stop loss. I'm trying to create a custom "Close" button that closes the position and working orders without disabling the strategy. I'm good with creating the button but haven't figured out the logic behind closing open positions and cancelling working orders without disabling the strategy. Any guidance would be appreciated.Tags: None
-
Hello jclose,
Thank you for your post.
<Account>.CancelAllOrders() could be used to cancel all orders on an instrument. This method can be used in a NinjaScript strategy.
See this help guide page for more information about accessing the Account class and sample code: https://ninjatrader.com/support/help...ount_class.htm
See this help guide page about <Account>.CancelAllOrders() and sample code: https://ninjatrader.com/support/help...lallorders.htm
Another way to cancel all orders from the strategy is you can loop through the orders in the account and cancel them with CancelOrder().
See this forum thread for more information about looping through orders on the account and canceling them with CancelOrder(): https://ninjatrader.com/support/foru...17#post1130617
Please let me know if I may further assist.
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by NTEducationTeam, Yesterday, 01:49 PM
|
0 responses
17 views
0 likes
|
Last Post
![]() |
||
Started by NTEducationTeam, Yesterday, 01:24 PM
|
0 responses
18 views
0 likes
|
Last Post
![]() |
||
Started by saltminer, 07-07-2025, 01:43 PM
|
1 response
115 views
0 likes
|
Last Post
|
||
Started by idude, 07-08-2025, 05:06 AM
|
0 responses
53 views
0 likes
|
Last Post
![]()
by idude
07-08-2025, 05:06 AM
|
||
Started by music_p13, 07-05-2025, 11:33 PM
|
1 response
53 views
0 likes
|
Last Post
|
Comment