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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      45 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
      31 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
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X