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, 05-11-2026, 05:56 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      32 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      195 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      358 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      278 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X