Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Flatten everything"

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

    "Flatten everything"

    I've always had with this curiosity to know which programmatic solution best approximates best the right click on the position tab "Flatten everything" which appears to be the most reliable method.
    I am interested in a solution that could stop the strategies and one that would not.

    I tried

    1) submissionAccount.Flatten(new[] { Instrument.GetInstrument(Instrument.ToString()) })

    2) A file OIF ---- "FLATTENEVERYTHING;;;;;;;;;;;;";

    3) [DllImport("NTDirect.dll", EntryPoint = "FlattenEverything")]
    public static extern void FlattenEverything();


    4) CancelAllOrders(Instrument instrument)

    5) Account.Flatten(new [] { Instrument.GetInstrument("ES 12-15") });

    6) Getting positions and submit the closing order with CreateOrder

    Any suggestion or comment?
    Best
    Gio

    #2
    My question is, which one of these methods matches the flattening everything of the position tab/chart-trader chart?

    Comment


      #3
      Hello,

      For NinjaScript strategies there is no Flatten everything for all instruments on an account. The closest thing is .Flatten() but you need to pass in a specific instrument is used on an Account basis, which would be using the AddOn approach. So you would need to get all positions on the account and call flatten on each instrument.

      Comment


        #4
        Thank you Gaby

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        43 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        21 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        30 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        50 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        40 views
        0 likes
        Last Post CarlTrading  
        Working...
        X