Please write in English here.
No code no help - how?
1.Used absolute paths instead of relative paths.
That is your problem.
You can't read (or write) outside the sandbox with normal code.
File Write Problem (Error: 5002) - Expert Advisors and Automated Trading - MQL5 programming forum #1-2 (2020)
For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means, cannot be outside the file sandbox.
FileOpen - File Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
That is your problem.
You can't read (or write) outside the sandbox with normal code.
File Write Problem (Error: 5002) - Expert Advisors and Automated Trading - MQL5 programming forum #1-2 (2020)
I have read it but I am just a little messed, I put my file in the "permitted folder", but my EA still can't find it.
signalFilePath = TerminalInfoString(TERMINAL_COMMONDATA_PATH) + "\\MQL5\\Files\\" + SignalFileName;
string ReadPythonSignal() { string signal = ""; int retry_count = 0; int max_retries = 5; // max tries int retry_delay = 1000; // gap(ms) while (retry_count < max_retries) { Print("Attempt to read the signal: ", signalFilePath, " (the ", retry_count + 1, " times attemption)"); if (!FileIsExist(signalFilePath)) { Print("The file doesn't exist: ", signalFilePath); Sleep(retry_delay); // Try after a while retry_count++; continue; } int handle = FileOpen(signalFilePath, FILE_READ | FILE_CSV | FILE_ANSI | FILE_COMMON); if (handle != INVALID_HANDLE) { Print("File has been opened sucessfully!"); string content = FileReadString(handle); FileClose(handle); // Deal with the content of the file return content; } else { int error = GetLastError(); Print("Can't open the file, the code: ", error, ", description: ", CustomErrorDescription(error)); Sleep(retry_delay); // Try after a while retry_count++; } } Print("Failed to read the file, have tried for so many times"); return signal; }
My outputs are:
2024.08.16 00:55:21.830 Glass_Model_Assistant (BTCUSD,D1) Attempt to read the signal: C:\Users\ASUS\AppData\Roaming\MetaQuotes\Terminal\Common\MQL5\Files\signal.csv (the x times attemption) 2024.08.16 00:55:21.830 Glass_Model_Assistant (BTCUSD,D1) The file doesn't exist: C:\Users\ASUS\AppData\Roaming\MetaQuotes\Terminal\Common\MQL5\Files\signal.csv
signalFilePath = TerminalInfoString(TERMINAL_COMMONDATA_PATH) + "\\MQL5\\Files\\" + SignalFileName;
Apparently you can't read. Did you read the link provided? Remove the path and make sure your file is in the approprate place.
- Files are at “«DataFolder»\MQLx\Files”.
- In the tester, files are at “«DataFolder»\MQLx\Tester\Files”.
Apparently you can't read. Did you read the link provided? Remove the path and make sure your file is in the approprate place.
- Files are at “«DataFolder»\MQLx\Files”.
- In the tester, files are at “«DataFolder»\MQLx\Tester\Files”.
Thank you so much, the problem has been solved!
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello, I'm developing an EA that needs to read a signal file generated by a Python script. However, the EA is unable to detect or access this file, even though I've confirmed that the file exists in the correct location (error code 5002). What's more confusing is that when I try to make the EA create a sample signal file in the same directory as the actual signal file, the EA can successfully create a new file.
Attempted Solutions
1.Used absolute paths instead of relative paths.
2.Checked and confirmed that MT5's file system access permissions are enabled.
3.Ran MT5 as administrator.
4.Manually created a simple test file and attempted to access it, which also failed.
The Following code is the piece that I make the EA read the signal file made by Python.