Download MetaTrader 5

FileOpen function can't work in backtest?

To add comments, please log in or register
sanzida12
149
sanzida12  

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.

Alain Verleyen
Moderator
32063
Alain Verleyen  
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.
sanzida12
149
sanzida12  
Alain Verleyen:
You need to use tester_file directive.


Dear Alain Verleyen,

How i use tester file direction?

Alain Verleyen
Moderator
32063
Alain Verleyen  
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

To add comments, please log in or register