Collect data into excel

 

Hello,

I wrote an EA to collect data from MT4 into excel. I need the high, low and the day of the week of an hourly bar.And I use it as backtest . So I set a starting date and an end date.

I get all the info in excel. BUT! I get a limit number of lines, only 274 lines of data.

Is it possible to get more data?

Thanks in advance.

This is my code:

int start()

{

int barcheck = Bars;

static int LastLine = 0;

if(LastLine == 0 || LastLine < barcheck)

{

int handle=FileOpen("Test.csv", FILE_CSV|FILE_READ|FILE_WRITE,";");

if(handle>0)

{

double dHigh =iHigh(NULL,0,1);

double dLow = iLow(NULL,0,1);

int iDayOfWeek = TimeDayOfWeek(Time[1]);

FileSeek(handle,0,SEEK_END);

FileWrite(handle,Symbol(),DoubleToStr(dHigh,5),DoubleToStr(dLow,5),TimeToStr(Time[1],5),DoubleToStr(iDayOfWeek,0));

FileClose(handle);

LastLine = barcheck;

handle=0;

}

}

}

 

Please use this to post code . . . it makes it easier to read.

 
Dropje:

Hello,

I wrote an EA to collect data from MT4 into excel. I need the high, low and the day of the week of an hourly bar.And I use it as backtest . So I set a starting date and an end date.

I get all the info in excel. BUT! I get a limit number of lines, only 274 lines of data.

Maybe that is all the data you have on your chart, Print("Bars = ", Bars ); and find out.
 
int start()
  {
  int barcheck = Bars;
  static int LastLine = 0;
  if(LastLine == 0 || LastLine < barcheck)
  {
   int handle=FileOpen("Test.csv", FILE_CSV|FILE_READ|FILE_WRITE,";");
       if(handle>0)
       {
       double dHigh =iHigh(NULL,0,1);
       double dLow = iLow(NULL,0,1);
       int iDayOfWeek = TimeDayOfWeek(Time[1]);
       FileSeek(handle,0,SEEK_END);
       FileWrite(handle,Symbol(),DoubleToStr(dHigh,5),DoubleToStr(dLow,5),TimeToStr(Time[1],5),DoubleToStr(iDayOfWeek,0));
       FileClose(handle);
       LastLine = barcheck;
       handle=0; 
         }
      }
  }
Thanks RaptorUK
 

I have 1509 bars .

The issue is resolved. It is working!. The problem was the historical data.

 

My suggestion - cut/paste this code into script, rather than EA.

Believe me, the convenience will make you smiling...

 
diostar:

My suggestion - cut/paste this code into script, rather than EA.

Believe me, the convenience will make you smiling...


You are write, but with this EA you can also transfer the value of every indicator into excel.

I use it to analyze an idea.

Reason: