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

How to get list of accounts and their balances

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

    How to get list of accounts and their balances

    Hi,

    1) How to get a list of available accounts from NinjaScript?
    2) How to get balance for each of those accounts?

    Many thanks!

    #2
    Hello Alex.nt,

    1. This is not something that is not supported. Note that there is a indicator on our NinjaScript File Sharing Section of our Forum that will access accounts that you may view for some hints.

    2. You may use the GetAccountItem() method to get values from your account that the strategy is running on.

    Let us know if we can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Sorry, could you please let me know the link to that topic? It appears there are tons of threads... if it is possible, of course!

      Comment


        #4
        Actually, thank to Klaus Hengher's hint, I found the answer:

        string currentAccountName = ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"].Text;

        for (int i = 0; i <= NinjaTrader.Cbi.Globals.Accounts.Count - 1; ++i)
        {
        Print(string.Format("{0}: {1}"
        , NinjaTrader.Cbi.Globals.Accounts[i].Name
        , NinjaTrader.Cbi.Globals.Accounts[i].GetAccountValue(AccountItem.CashValue, Currency.UsDollar)));
        }

        I believe this might work.
        Last edited by alex.nt; 02-06-2013, 03:26 PM.

        Comment


          #5
          did this work for you?

          Originally posted by alex.nt View Post
          Actually, thank to Klaus Hengher's hint, I found the answer:

          string currentAccountName = ChartControl.Controls["pnlChartTrader"].Controls["ctrChartTraderControl"].Controls["cboAccount"].Text;

          for (int i = 0; i <= NinjaTrader.Cbi.Globals.Accounts.Count - 1; ++i)
          {
          Print(string.Format("{0}: {1}"
          , NinjaTrader.Cbi.Globals.Accounts[i].Name
          , NinjaTrader.Cbi.Globals.Accounts[i].GetAccountValue(AccountItem.CashValue, Currency.UsDollar)));
          }

          I believe this might work.

          Comment


            #6
            Not like that, I remember I had to make some correction. Try to use Currency.Unknown instead. Also, you can always go over Accounts collection directly.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            5 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            12 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            13 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,982 views
            3 likes
            Last Post jhudas88  
            Working...
            X