string terminal_data_path=TerminalInfoString(TERMINAL_COMMONDATA_PATH); string signalFile=terminal_data_path + "\\Files\\" + "output.csv";
Now I have different error. it is 5002
Using files is tricky. I finally got something that works:
#import "kernel32.dll" int CopyFileW(string,string,int); #import //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- string filename = "output.csv"; string source_path = "D:\\"; string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH); string sourcefile = source_path + "\\" + filename; string signalFile=terminal_data_path + "\\" + filename; CopyFileW(sourcefile, signalFile,0); int handle = FileOpen(filename, FILE_WRITE | FILE_CSV | FILE_READ); if(handle == INVALID_HANDLE){ Print(GetLastError()); return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); }
The idea is to use the Windows API to copy the file from D:\ to the terminal data path, which depends and we don't want to bother. Then it opens successfully, providing the right parameters to FileOpen():
FILE_WRITE | FILE_CSV | FILE_READ
This is also tricky.
Finally, allow the import of DLLs from the options of the terminal:
This is odd. Really strange. I noticed I have two MT5 installed. Each of them on different places. One is installed normally on Program Files. The other in AppData\Roaming\MetaTrader. I am able to uninstall the first one, but have no idea about the other.
Anyway, problem solved, because I was reffering from the first MY5 to the place of another one. Now, as I am working with only one MT5, there is no problem. Thank you Frederic for the effort.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have read meny threads and docs, followed them but non of them work.
here the place where my file is
C:\Users\marti\AppData\Roaming\MetaQuotes\Terminal\F762D69EEEA9B4430D7F17C82167C844\MQL5\Files
I found it in File > Open Data Folder
In my code I have the path set as follow:
string signalFile="output.csv";
int file_handle = FileOpen("output.csv", FILE_READ | FILE_CSV | FILE_ANSI | FILE_COMMON, ';');
if (file_handle != INVALID_HANDLE) {
But I also tried
string terminal_data_path=TerminalInfoString(TERMINAL_DATA_PATH);
string signalFile= terminal_data_path + "\\MQL5\\Files\\" + "output.csv";
And also
C:\Users\marti\AppData\Roaming\MetaQuotes\Terminal\F762D69EEEA9B4430D7F17C82167C844\MQL5\Files\outpust.csv
Nothing works. When I run my program (Ctrl + F5), when executed, during running program, I get error 5004.
I appreciate if anyone finds a way to push me.