Read CSV file
J Sky :
The file is in the 'Files' directory - IT'S IMPORTANT !!!

Here is the code:
//+------------------------------------------------------------------+ //| FileOpen csv.mq5 | //| Copyright © 2019, Vladimir Karputov | //+------------------------------------------------------------------+ #property copyright "Copyright © 2019, Vladimir Karputov" #property version "1.000" #property description "Open the CSV file at the specified path" #property script_show_inputs //--- input parameters input string InpDirectoryName = "Data"; // Directory name input string InpFileName = "hi.csv"; // File name //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- int filehandle=FileOpen(InpDirectoryName+"\\"+InpFileName,FILE_READ|FILE_CSV); if(filehandle!=INVALID_HANDLE) { PrintFormat("%s file is available for reading",InpFileName); PrintFormat("File path: %s\\Files\\",TerminalInfoString(TERMINAL_DATA_PATH)); //--- close the file FileClose(filehandle); PrintFormat("Data is read, %s file is closed",InpFileName); } else PrintFormat("Failed to open %s file, Error code = %d",InpFileName,GetLastError()); } //+------------------------------------------------------------------+
Here's a good result:
2021.08.18 07:21:24.911 FileOpen csv (AUDUSD,M10) hi.csv file is available for reading 2021.08.18 07:21:24.911 FileOpen csv (AUDUSD,M10) File path: C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\Files\ 2021.08.18 07:21:24.911 FileOpen csv (AUDUSD,M10) Data is read, hi.csv file is closed
Files:
FileOpen_csv.mq5
3 kb
Hello,
Sorry there are a million topics on this already but I've read through heaps of them and can't get it to work.
I directly copied the example from the documentation, but changed from a bin to a csv.
I place my file in the directory, and every time I run the expert in tester, I get the error code 5004 and the file gets deleted.