Writing EA output/messages to output file(s)

 
Hi,

I tried the FileWrite function and it works, but it writes only one line...how do I use it in 'append' mode so the output file can store the complete history of EA run in backtesting? I'm attaching my code below...
handle=FileOpen("Pivots", FILE_CSV|FILE_WRITE, ';'); if(handle>0) { // write table columns headers FileWrite(handle, "Time;High;Low;Close;Pivot;R1;R2;R3;S1;S2;S3"); // write data FileWrite(handle, Time[1], High[1], Low[1], Close[1],Pivot, R1, R2, R3, S1, S2, S3) ; FileClose(handle); }
 
handle=FileOpen("Pivots", FILE_CSV|FILE_WRITE|FILE_READ, ';');
 
Dear Stringo,

No luck! I still get a single row of values written in my output file...here is the code...

//Write to the file - by default, all files are stored in metatrader 4\tester\Files directory handle=FileOpen("Pivots", FILE_CSV|FILE_WRITE|FILE_READ, ';'); if(handle>0) { // write table columns headers FileWrite(handle, "Time;High;Low;Close;Pivot;R1;R2;R3;S1;S2;S3"); // write data FileWrite(handle, Time[1], High[1], Low[1], Close[1],Pivot, R1, R2, R3, S1, S2, S3) ; FileClose(handle); } //Print("High=",YH," Low=",YL," Close=",YC," Pivot=",Pivot," R1=",R1," R2=",R2," R3=",R3," S1=",S1," S2=",S2," S3=",S3); return(0); }


Edited: 03 Feb 06 to make the thread more presentable...
 
use fileseek(handle,0,seek_end) right after you open the file for edit. before writing the new line to ti
 
Aaha!

This works....also, thanks for the link! Back to coding now... :)
 
Maratha:
Hi,

I tried the FileWrite function and it works, but it writes only one line...how do I use it in 'append' mode so the output file can store the complete history of EA run in backtesting? I'm attaching my code below...
handle=FileOpen("Pivots", FILE_CSV|FILE_WRITE, ';');
  if(handle>0)
    {
     // write table columns headers
     FileWrite(handle, "Time;High;Low;Close;Pivot;R1;R2;R3;S1;S2;S3");
     // write data
     FileWrite(handle, Time[1], High[1], Low[1], Close[1],Pivot, R1, R2, R3, S1, S2, S3) ;
     FileClose(handle);
    }

Dear,

I realy need your help, since I am trying to do exactly what you are doing, I am looking for away to write the complete history of the EA run in backtesting into a file , the reason is that i want to add more studies during the backtesting. so this way i can have a full table of entries exits and MAE and MFE.

Please help, I wanted to know how and where I can place such code in my EA or is it only a script?
plesese reply ...

thank you
Reason: