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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        87 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        128 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        65 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        117 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        67 views
        0 likes
        Last Post PaulMohn  
        Working...
        X