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 Max238, Today, 01:28 AM
            4 responses
            36 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by r68cervera, Today, 05:29 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by geddyisodin, Today, 05:20 AM
            1 response
            11 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by timko, Today, 06:45 AM
            2 responses
            14 views
            0 likes
            Last Post NinjaTrader_ChristopherJ  
            Started by habeebft, Today, 07:27 AM
            0 responses
            7 views
            0 likes
            Last Post habeebft  
            Working...
            X