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 NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      66 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      141 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      75 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      46 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      51 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X