File Read Array Help !!

 

I have a csv file MACD.csv I want to learn how to load data into script and EA's but i'm stuck , no array is read and sometimes changing the code leads to long array numbers that i find irrelevant to what I want

2021.07.14 17:00:00;false;20
2021.07.13 09:00:00;true;20
2021.07.13 00:00:00;false;20
2021.07.12 17:00:00;true;20
2021.07.12 16:00:00;false;20
2021.07.12 13:00:00;true;20
2021.07.08 12:00:00;false;20
2021.07.06 11:00:00;true;20
2021.07.02 20:00:00;false;20
2021.06.28 02:00:00;true;20

This is my file read code inside a script

void OnStart() 
  { 
//--- structure array 
   int arr[]; 
//--- file path 
   string path=InpDirectoryName+"//"+InpFileName; 
//--- open the file 
   ResetLastError(); 
   int file_handle=FileOpen(path,FILE_READ|FILE_BIN); 
   if(file_handle!=INVALID_HANDLE) 
     { 
      //--- read all data from the file to the array 
      //FileReadArray(file_handle,arr);
      int size=ArraySize(arr); 
      FileReadArray(file_handle,arr);
      //--- receive the array size 
      Print(" Array Size ",size);
      //--- print data from the array 
      for(int i=0;i<size;i++) 
         Print("Date = ",arr[i]," Signal = ",arr[i]); 
      Print("Total data = ",size); 
      //--- close the file 
      FileClose(file_handle); 
     } 
   else 
      Print("File open failed, error ",GetLastError()); 
  }

help me how to do that

 
Omega J Msigwa: I have a csv file MACD.csv I want to learn how to load data into script and EA's but i'm stuck , no array is read and sometimes changing the code leads to long array numbers that i find irrelevant to what I want. This is my file read code inside a script. help me how to do that

Its a Text file, not a Binary file. Open it as a CSV text (FILE_CSV), and define the ";" as the field delimiter. Don't read it in as an Array. Use FileReadNumber() and/or FileReadString().

FileOpen - File Functions - MQL4 Reference
FileOpen - File Functions - MQL4 Reference
  • docs.mql4.com
FileOpen - File Functions - MQL4 Reference
 
If you had bothered to read the documentation, FileReadArray only works for binary files. Read each number into an array.