Accessing Account balance from strategy.  [SOLVED]

Questions about MultiCharts .NET and user contributed studies.
robbob
Posts: 46
Joined: 26 Jan 2013
Has thanked: 2 times
Been thanked: 3 times

Accessing Account balance from strategy.

Postby robbob » 12 Mar 2013

How would I access the current account balance from a strategy? I see there is an Account property that is accessible from the strategy, but it is a String and not an object. Any hints?

Thanks,
-Rob

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Accessing Account balance from strategy.

Postby Henry MultiСharts » 14 Mar 2013

Hello Rob,

You need to use Account.Balance Property. Example:

Code: Select all

TradeManager.ProcessEvents();
...
TradeManager.TradingData.Accounts.Items[0].Balance;

robbob
Posts: 46
Joined: 26 Jan 2013
Has thanked: 2 times
Been thanked: 3 times

Re: Accessing Account balance from strategy.

Postby robbob » 17 Mar 2013

I'm getting an IndexOutOfRangeException when attempt to call:

TradeManager.TradingData.Accounts.Items[0].Balance;

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Accessing Account balance from strategy.  [SOLVED]

Postby Henry MultiСharts » 18 Mar 2013

You need to check the amount of elements in the Accounts.Items collection first, then you can extract a value from this collection. The attached sample code will output profile name and balance to the Output tab of the PL .Net Editor.
Attachments
Test_GetAccountInfo.pln
(1.94 KiB) Downloaded 782 times


Return to “MultiCharts .NET”