Thanks!
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
Flatten Everything Event
Collapse
X
-
Hello Rudmax,
Thank you for your post.
FlattenEverything() is an undocumented/unsupported method. When calling FlattenEverything() we are able to see positions close but we are unable to differentiate between the closed positions because the order name is not unique and only returns "Close".
With that being said, you could subscribe to account-level OrderUpdate events to monitor orders sent to an account. When we create our own order, we can give it a unique name that we can identify in the account's OrderUpdate event. A custom method could be created that loops through your account Positions and checks if that position is Long or Short followed by submitting an order in the opposite direction of the position to close it. For example, if we are in a long position, a sell order will be placed in order to close out that long position.
Please see the attached example strategy which demonstrates how a custom method may be used to flatten all positions on an account.
Also, I have linked the following help guide pages for more information.
OrderUpdate - https://ninjatrader.com/support/help...rderupdate.htm
CreateOrder - https://ninjatrader.com/support/help...tegycreate.htm
Account Positions - https://ninjatrader.com/support/help...ns_account.htm
Let us know if we may further assist.Attached FilesBrandon H.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ScottWalsh, Today, 06:52 PM
|
4 responses
32 views
0 likes
|
Last Post
by ScottWalsh
Today, 07:40 PM
|
||
Started by olisav57, Today, 07:39 PM
|
0 responses
4 views
0 likes
|
Last Post
by olisav57
Today, 07:39 PM
|
||
Started by trilliantrader, Today, 03:01 PM
|
2 responses
19 views
0 likes
|
Last Post
by helpwanted
Today, 07:25 PM
|
||
Started by cre8able, Today, 07:24 PM
|
0 responses
6 views
0 likes
|
Last Post
by cre8able
Today, 07:24 PM
|
||
Started by Haiasi, Today, 06:53 PM
|
1 response
5 views
0 likes
|
Last Post Today, 07:05 PM |
Comment