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 selu72, Today, 02:01 PM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Started by WHICKED, Today, 02:02 PM
            2 responses
            11 views
            0 likes
            Last Post WHICKED
            by WHICKED
             
            Started by f.saeidi, Today, 12:14 PM
            8 responses
            21 views
            0 likes
            Last Post f.saeidi  
            Started by Mikey_, 03-23-2024, 05:59 PM
            3 responses
            51 views
            0 likes
            Last Post Sam2515
            by Sam2515
             
            Started by Russ Moreland, Today, 12:54 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Erick  
            Working...
            X