GetRTAccountEquity  [SOLVED]

Questions about MultiCharts and user contributed studies.
no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

GetRTAccountEquity

Postby no erocla » 04 Apr 2014

Hello all,

this code:

Code: Select all

vars: lot(0),STOPLOSS(0),TAKEPROFIT(0),up(0),dw(0),equity(0);
input: period(20),dev(2);

equity = GetRTAccountEquity(GetAccountID);

if LastBarOnChart then begin
Value1 = Text_New_s(Date, Time_s, High + 6 * MinMove/PriceScale, NumToStr(equity , 0));
Text_SetColor(Value1, Yellow);
end;

lot = 100000;

up = BollingerBand(h,period,dev);
dw = BollingerBand(l,period,-dev);

if ( c > up ) then
BUY ( "LONG") lot SHARE NEXT BAR AT open;

if ( c < dw ) then
SELLSHORT ("SHORT") lot SHARE NEXT BAR AT OPEN;


SetStopLoss(200);
SetProfitTarget(200);
assume that equity = 0. Why this?

Thank all for any answer or suggestion
No Erocla

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

Re: GetRTAccountEquity

Postby Henry MultiСharts » 04 Apr 2014

Hello No Erocla,

Have you configured the symbol mapping, selected the broker plugin for your strategy, then turned on the auto trading?

no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Re: GetRTAccountEquity

Postby no erocla » 04 Apr 2014

Thank you very much for answer, my autotrading works correctly so:

Yes, i've configured symbol mapping
Yes, i've selected correct broker plugin (IB)

Ok putting autotrading on it seems to work, but i cannot backtest strategy now.

I'am sure that last week i 've backtested my strategy using a money management based on account equity, and all works correctly.

I don t know why now it doesn t work, maybe for last update ?
There's no way to get account balance with autotrade off ?

Thank you again for your time
No Erocla

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

Re: GetRTAccountEquity

Postby Henry MultiСharts » 04 Apr 2014

GetRTAccountEquity returns current account balance from broker in realtime. This value cannot be used for backtesting, only for realtime trading.

In backtesting you can calculate the current balanse using the following formula:
InitialCapital + netprofit + openpositionprofit

no erocla
Posts: 134
Joined: 31 May 2013
Has thanked: 60 times
Been thanked: 7 times

Re: GetRTAccountEquity

Postby no erocla » 04 Apr 2014

Ok, but how is it possibile so ?

Image

Anyway, the important is that it works on live trading.

Regards
No Erocla

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

Re: GetRTAccountEquity  [SOLVED]

Postby Henry MultiСharts » 04 Apr 2014

Please be more procise in description. What is incorrect exactly?
GetAccountID can get your account # only the auto trading has been turned on. You can turn off the auto trading, recalculate the strategy and it will still remember the account # (will fix that, this is not correct). If you specify manually the account # in GetRTAccountEquity then it will return the account equity even if auto trading is not turned on. But still this is a realtime value and there is no prebuilt way to have historical values of it.


Return to “MultiCharts”