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

Getting account value (Real account)

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

    Getting account value (Real account)

    Hi,

    I am trying to get the account value of my real account.

    I have used the script provided by ChelseaB on the next post:



    The thing is that using the next line of code I get the account value of Sim101 account:

    Print(string.Format("{0} | Account: {2} | Buying Power: {2} | CashValue: {3}", Time[0], Account.Name, GetAccountValue(AccountItem.BuyingPower), GetAccountValue(AccountItem.CashValue) ));

    How can I get the account value of my real account? How should I change the Account.Name parameter?

    Thanks in advance.
    Regards.

    #2
    Hello Plaket,

    Thank you for your post.

    Looks like it'll print the information for whichever account it's running on - so you would need to run this on your live account for it to report information for that account.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thank you,

      ​​​​​Another one please, how can I get the list of the open positions on the account?

      I know how to get this of a specific strategy, can I get it of the overal account?

      Thanks.

      Comment


        #4
        Hello Plaket,

        Thank you for your reply.

        You would need to query all the accounts in the database that you are connected to in order to get any information for them. This is unsupported programming with NinjaTrader 7 but here is a link to get you started:



        Let me know if I can be of further assistance.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Hi - I am getting 0 on both Sim and Live account -
          foreach (Account acct in Cbi.Globals.Accounts)
          {

          Print(acct.Name.ToString() + acct.GetAccountValue(AccountItem.BuyingPower,Curre ncy.UsDollar).ToString());
          }
          Is this correct - is there a setting somewhere that I am missing?

          thanks

          Comment


            #6
            Hello Mindset,

            Thank you for your reply.

            While Account access isn't technically supported in NinjaTrader 7, this should work properly for you:

            foreach (Account acct in Cbi.Globals.Accounts) {

            Print(acct.Name.ToString() + acct.GetAccountValue(AccountItem.BuyingPower,Curre ncy.Unknown).ToString());
            }

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by usazencort, Today, 01:16 AM
            0 responses
            1 view
            0 likes
            Last Post usazencort  
            Started by kaywai, 09-01-2023, 08:44 PM
            5 responses
            603 views
            0 likes
            Last Post NinjaTrader_Jason  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            6 responses
            22 views
            0 likes
            Last Post xiinteractive  
            Started by Pattontje, Yesterday, 02:10 PM
            2 responses
            21 views
            0 likes
            Last Post Pattontje  
            Started by flybuzz, 04-21-2024, 04:07 PM
            17 responses
            230 views
            0 likes
            Last Post TradingLoss  
            Working...
            X