FileOpen function can't work in backtest?

 

Dear Guys

I wrote a code below :

  handle=FileOpen(File_Name,FILE_READ|FILE_CSV|FILE_ANSI);
  
  if(handle==INVALID_HANDLE)
  {
   Alert("Cannot Read File Error : "+DoubleToString(GetLastError(),0));
  }else{

    while(!FileIsEnding(handle))
    {
      string text=FileReadString(handle);
      }
   }


When i an run this EA on chart then FileOpen is work well. it can read file. but same EA when i try on backtest FileOpen can't work. it show error:

 " Alert: Cannot Read File Error : 5004"

how can i solve this problem. i want EA also work in backtest.

Thansk.

 
sanzida12:

Dear Guys

I wrote a code below :


When i an run this EA on chart then FileOpen is work well. it can read file. but same EA when i try on backtest FileOpen can't work. it show error:

 " Alert: Cannot Read File Error : 5004"

how can i solve this problem. i want EA also work in backtest.

Thansk.

You need to use tester_file directive.
 
Alain Verleyen:
You need to use tester_file directive.


Dear Alain Verleyen,

How i use tester file direction?

 
sanzida12:


Dear Alain Verleyen,

How i use tester file direction?

Did you read the documentation (I provide you the link) ?

See also https://www.mql5.com/en/forum/16439#comment_703226

 

Or you can put the file under "files" folder that you find under Tester. It may look something like below:


C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\F50DC1E258BD3364F7685D3C3DF0A89B\tester\files

You might have placed files under below path. 

C:\Users\Administrator\AppData\Roaming\MetaQuotes\Terminal\F50DC1E258BD3364F7685D3C3DF0A89B\MQL4\files