Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Account class

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

    Account class

    Hello,

    When I try to access the Account class I get an error basically trying to reference an instance that is not an object.

    I'm assuming then that Account is not static and I need to do myAccount = new Account(), before using it?

    Just wanted to confirm.

    Also what is the constructor signature?

    Mtany Thanks, Caesar.
    Last edited by Skechers; 09-28-2022, 03:11 PM.

    #2
    Hello Skechers,

    Thanks for your post.

    Creating a new account is not documented or supported.

    You could use Account.All to access a collection of all connected accounts.

    Please see the sample code on the Account help guide page linked below. This sample code demonstrates finding an account, such as Sim101, and assigning it to an Account variable.

    Account: https://ninjatrader.com/support/help...ount_class.htm
    Account.All: https://ninjatrader.com/support/helpGuides/nt8/all.htm

    From the sample code:

    private Account myAccount;

    protected override void OnStateChange()
    {​

    if (State == State.SetDefaults)
    {
    // Find our Sim101 account
    lock (Account.All)
    myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");
    ...
    }
    }​


    Let me know if I may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hello BRandon,

      OK, so to cancel all orders, all I need to do is:

      Account.CancelAllOrders(Instrument);

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X