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 hazylizard, Today, 08:38 AM
            2 responses
            8 views
            0 likes
            Last Post hazylizard  
            Started by geddyisodin, Today, 05:20 AM
            2 responses
            17 views
            0 likes
            Last Post geddyisodin  
            Started by Max238, Today, 01:28 AM
            5 responses
            45 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by giulyko00, Yesterday, 12:03 PM
            3 responses
            13 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by habeebft, Today, 07:27 AM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Working...
            X