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 PaulMohn, Today, 12:36 PM
|
2 responses
16 views
0 likes
|
Last Post
by PaulMohn
Today, 01:48 PM
|
||
Started by Conceptzx, 10-11-2022, 06:38 AM
|
2 responses
53 views
0 likes
|
Last Post
by PhillT
Today, 01:47 PM
|
||
Started by Kaledus, Today, 01:29 PM
|
0 responses
3 views
0 likes
|
Last Post
by Kaledus
Today, 01:29 PM
|
||
Started by yertle, Yesterday, 08:38 AM
|
8 responses
37 views
0 likes
|
Last Post
by ryjoga
Today, 01:22 PM
|
||
Started by rdtdale, Today, 01:02 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:13 PM |
Comment