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!
See more
See less

Partner 728x90

Collapse

Flatten Everything Event

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Flatten Everything Event

    Is there any way to capture the FlattenEverything event?

    Thanks!

    #2
    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 Files
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by PaulMohn, Today, 12:36 PM
    2 responses
    16 views
    0 likes
    Last Post PaulMohn  
    Started by Conceptzx, 10-11-2022, 06:38 AM
    2 responses
    53 views
    0 likes
    Last Post PhillT
    by PhillT
     
    Started by Kaledus, Today, 01:29 PM
    0 responses
    3 views
    0 likes
    Last Post Kaledus
    by Kaledus
     
    Started by yertle, Yesterday, 08:38 AM
    8 responses
    37 views
    0 likes
    Last Post ryjoga
    by ryjoga
     
    Started by rdtdale, Today, 01:02 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_LuisH  
    Working...
    X