MQL4 - automated forex trading   /  

Forum

Writing EA output/messages to output file(s)

Back to topics list To post a new topic, please log in or register

avatar
17
Maratha 2006.01.22 07:56 
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); }
Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization (Cont.)

Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization (Cont.)

In this article the author continues to analyze implementation algorithms of simplest trading systems and introduces backtesting automation. The article will be useful for beginning traders and EA writers.


avatar
Moderator
5198
stringo 2006.01.23 14:15 
handle=FileOpen("Pivots", FILE_CSV|FILE_WRITE|FILE_READ, ';');

avatar
17
Maratha 2006.01.30 01:21 
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...

avatar
5
iPlayGames 2006.01.30 10:00 
use fileseek(handle,0,seek_end) right after you open the file for edit. before writing the new line to ti

avatar
Moderator
5198
stringo 2006.01.30 13:21 

avatar
17
Maratha 2006.02.04 01:47 
Aaha!

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

avatar
2
fariselmafrosee 2007.05.27 08:15 
Maratha wrote:
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
Back to topics list  

To add comments, please log in or register