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 Taddypole, 04-26-2024, 02:47 PM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_Eduardo  
            Started by futtrader, 04-21-2024, 01:50 AM
            6 responses
            58 views
            0 likes
            Last Post futtrader  
            Started by sgordet, Today, 11:48 AM
            0 responses
            4 views
            0 likes
            Last Post sgordet
            by sgordet
             
            Started by Trader146, Today, 11:41 AM
            0 responses
            5 views
            0 likes
            Last Post Trader146  
            Started by jpapa, 04-23-2024, 07:22 AM
            2 responses
            22 views
            0 likes
            Last Post rene69851  
            Working...
            X