Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Brandon H.NinjaTrader Customer Service

    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 Klaus Hengher, Yesterday, 03:13 AM
      2 responses
      15 views
      0 likes
      Last Post Klaus Hengher  
      Started by Sebastian - TwinPeaks, Yesterday, 01:31 PM
      2 responses
      13 views
      0 likes
      Last Post Sebastian - TwinPeaks  
      Started by wbennettjr, 07-15-2017, 05:07 PM
      16 responses
      2,531 views
      1 like
      Last Post eladlevi  
      Started by Human#102, Yesterday, 09:54 AM
      2 responses
      8 views
      0 likes
      Last Post Human#102  
      Started by Patlpp, 08-16-2021, 03:10 PM
      10 responses
      500 views
      0 likes
      Last Post Joerg
      by Joerg
       
      Working...
      X