MQL5 - Issue is reading from file on EA - Wrong values captured

 

Dears,

as it is clear in subject i want to work with file in EA inside MQL5. be informed below code tested on MQL4 and worked properly.

Also i know i should insert file in EA separately to be used (another WHY in MQL5) using below code

#property tester_file "ALL_2018.csv"

i created an array of structure name "values" and below is my code inside OnInit() :

     Print ("---- Loading file '",Filename,"' started. Please Wait ...");
     flh = FileOpen(Filename,FILE_READ|FILE_CSV,",");
     if (flh != INVALID_HANDLE)
     {
       while (!FileIsEnding(flh))
       {
         str = FileReadString(flh); // <--- this works just once
         StringReplace(str,CharToString(34),"");
         if (str==_Symbol)
         {
           Print(str);
           ArrayResize(values,i+1);
           str = FileReadString(flh);
           StringReplace(str,CharToString(34),"");
           values[i].d_candle=(int) StringToInteger(str);
           str = FileReadString(flh);
           StringReplace(str,"-",".");
           StringReplace(str,CharToString(34),"");
           values[i].cnt_date = StringToTime(str);
           str = FileReadString(flh);
           StringReplace(str,CharToString(34),"");
           values[i].POINT1 = StringToDouble(str);
         }
         i++;
       }
       Print("File loaded successfully");
     }
     else print("Error in reading file ...");
     FileClose(flh);
As data contain many Symbols, i'd like to like just related Symbol to current chart and the file contain more than 2K rows in below structure

But during trace you may see the marked line inside the code which just run once and result is strange and unreadable content (seams Japanese to me)

do you have any idea why this may happen?

 
     flh = FileOpen(Filename,FILE_READ|FILE_CSV|FILE_ANSI,",");
 
Alain Verleyen:

Thanks a lot Alain, it works now

For my better understanding I'm asking. This code was working properly on MT4. What is the difference here in MT5 which FILE_ANSI should be mentioned

 
ArashB:

Thanks a lot Alain, it works now

For my better understanding I'm asking. This code was working properly on MT4. What is the difference here in MT5 which FILE_ANSI should be mentioned

mql5 default is FILE_UNICODE.

TIPS: Always read the documentation in first place when you have a problem.

 
Alain Verleyen #:

mql5 default is FILE_UNICODE.

TIPS: Always read the documentation in first place when you have a problem.

THANK YOUUUUUUUUUUUUUUUUU