I've spent just over 4 hours now searching and testing methods of getting the current accounts cashValue and save it as a local variable to calculate how many shares to purchase with 10% of that cashValue. I have finally found what appears correct however I want to confirm it.
Print(NinjaTrader.Cbi.Globals.Accounts[0].GetAccountValue(AccountItem.CashValue, Currency.Unknown).Value);
I connected to Sim101, opened a chart, and run a test strategy that only Printed this value and it returned what Sim101 account listed as Cash Value. Is this the proper method of doing this?
Part 2:
I've tried many variations of only using GetAccountValue(AccountItem.CashValue) as is documented however when run as above on Sim101 the Printed value is always 0. Example Statement: Print(GetAccountValue(AccountItem.CashValue));
Why is this?
I can add both of these statements to the same strategy and the first returns a proper value and the second still returns 0.
Part 3:
I've also found odd discrepancies when specifying the currency. I added both of the below lines to a blank strategy as above, run it on the Sim101 account and the first Print statement returns the Sim101's account cash value but the second Print statement returns 0.
Print(NinjaTrader.Cbi.Globals.Accounts[0].GetAccountValue(AccountItem.CashValue, Currency.Unknown).Value);
Print(NinjaTrader.Cbi.Globals.Accounts[0].GetAccountValue(AccountItem.CashValue, Currency.UsDollar).Value);
Why is this?
Thanks in advance,
Joe
Comment