Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Issue with Account.Flatten

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

    Issue with Account.Flatten

    I;ve emulated code from the NT 8 manual to flatten my positions but it is throwing an error:

    Code:

    Instrument myInstrument = Cbi.Instrument.GetInstrument("ES 12-15");
    myAccount.Flatten(myInstrument);

    Generates error CS1503 - Argument 1: cannot convert from 'NinjaTrader.Cbi.Instrument' to 'System.Collections.Generic.ICollection<NinjaTrade r.Cbi.Instrument>'

    Not sure if this is a bug or I've done something wrong.

    I've tried using just myAccount.Flatten(Instrument); and this doesn't work, however using myAccount.CancelAllOrders(Instrument); does work (compiles and closes orders as intended).

    Thanks
    daqu40
    NinjaTrader Ecosystem Vendor - QTradez

    #2
    I see our documentation is wrong here, I'll have that fixed up. Thanks.

    It's looking for a collection of instruments, even if that is just one:

    Code:
    Account.Flatten(new [] { Instrument.GetInstrument("ES 12-15") });
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thanks Matthew,

      Dissecting the error I figure this out. It would be helpful to others if the manual gets update to make this clear.
      daqu40
      NinjaTrader Ecosystem Vendor - QTradez

      Comment


        #4
        I've updated it now, please let me know if I can clarify anything else with this (or any other account) methods:

        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        673 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        379 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        578 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        582 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X