MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Find How 300 000+ Users Liven Up MQL5.com

Equity Indicator

Back to topics list To post a new topic, please log in or register
avatar
282
sunshineh 2010.10.10 16:45
 

Hello,

I want to programm the Equity as an Indicator. I tried it in this way, but it doesn't work

int init()
  { 
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,EquityBuffer);
   SetIndexLabel(0,"EquityBuffer");
   SetIndexDrawBegin(0,0);            

   return(0);
  }

int start()
  {
   int    limit;
   int    counted_bars=IndicatorCounted();
    //---- check for possible errors
   if(counted_bars<0) return(-1);
   //---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
    
   for(int k=0; k<limit; k++) 
   {
   EquityBuffer[k]  = AccountEquity();
   }
//----
   return(0);
  }

Can anybody tell me why?!

 
Lamborghini: Calm in the eye of the Huracan
Lamborghini: Calm in the eye of the Huracan
Ronnie Mansolillo | 25 October 2014, 20:19 | Views: 63
Seconds before the accident, I had noted the man in the right lane, or more precisely the Citroën C6 executive saloon he was driving. Always loved that car. The style holds up. It was about 5:30 p.m. -- prime accident time, statistics tell us—and traffic on the European Route E15 north of Lyon, France, was moving well.
avatar
893
7bit 2010.10.11 02:52 #
 
IIRC there is already something in the code base that does what you want. Its a bit more complicated since you will have to reconstruct the equity (simulate its changes) from the trade history and the old market prices at these times.
 
avatar
282
sunshineh 2010.10.11 12:48 #
 

Hi,

I saw the Equity_v8, which I can only use in a Strategietest or an already running EA, but not in a backtest (or can somebody explain me, how it also works in an backtest??) .

I also found the offline_charts, but the use from it is a little bit of circumstantial, so I can't change the timeframe without starting the backtest again and the chart isn't in the same window. l

 
avatar
893
7bit 2010.10.11 16:36 #
 
sunshineh:

Hi,

I saw the Equity_v8, which I can only use in a Strategietest or an already running EA, but not in a backtest (or can somebody explain me, how it also works in an backtest??) .

I also found the offline_charts, but the use from it is a little bit of circumstantial, so I can't change the timeframe without starting the backtest again and the chart isn't in the same window. l

Unfortunately an indicator on the backtest chart cannot access the backtest trades, it will wrongly access the real live trade history. This is a known bug in MT4, Metaquotes refuses to fix it, it seems they have stopped anything that has to do with mt4, they don't even respond to questions about MT4 bugs anymore.


For a backtest the only real option is recordEquity() (from offline_charts.mqh) compiled directly into the EA . I wrote this include exactly for this reason.

 
Back to topics list  

To add comments, please log in or register