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 wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            26 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, 02-22-2024, 01:11 AM
            5 responses
            32 views
            0 likes
            Last Post wzgy0920  
            Started by wzgy0920, Yesterday, 09:53 PM
            2 responses
            49 views
            0 likes
            Last Post wzgy0920  
            Started by Kensonprib, 04-28-2021, 10:11 AM
            5 responses
            192 views
            0 likes
            Last Post Hasadafa  
            Started by GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,234 views
            0 likes
            Last Post xiinteractive  
            Working...
            X