Page 1 of 1

GetRTAccountEquity

Posted: Apr 04 2014
by no erocla
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

Re: GetRTAccountEquity

Posted: Apr 04 2014
by Henry MultiСharts
Hello No Erocla,

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

Re: GetRTAccountEquity

Posted: Apr 04 2014
by no erocla
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

Re: GetRTAccountEquity

Posted: Apr 04 2014
by Henry MultiСharts
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

Re: GetRTAccountEquity

Posted: Apr 04 2014
by no erocla
Ok, but how is it possibile so ?

Image

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

Regards
No Erocla

Re: GetRTAccountEquity  [SOLVED]

Posted: Apr 04 2014
by Henry MultiСharts
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.