Hello everyone,
My MQL5 indicator is supposed to import trade data from a CSV file and display them on the chart. The CSV file is properly exported and placed in the Terminal/Common/Files folder, but the indicator keeps returning error 5002 saying the file doesn't exist. The file is definitely there, what could be causing this file access problem?
Thanks!
Hello everyone,
My MQL5 indicator is supposed to import trade data from a CSV file and display them on the chart. The CSV file is properly exported and placed in the Terminal/Common/Files folder, but the indicator keeps returning error 5002 saying the file doesn't exist. The file is definitely there, what could be causing this file access problem?
Thanks!
Did you check what error 5002 means ?
Show your code if you need coding help.
Forum on trading, automated trading systems and testing trading strategies
How to the id:5002 problem of FileOpen?
William Roeder, 2024.08.05 15:11
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)
File Write Problem (Error: 5002) - Expert Advisors and Automated Trading - MQL5 programming forum #1-2 (2020)
and FolderDelete using TERMINAL_DATA_PATH - General - MQL5 programming forum (2017)
Thank you all! every time i get this error message below:
"File does not exist: C:\Users\pc\AppData\Roaming\MetaQuotes\Terminal\Common\Files\TradeVisualizer_XAUUSD.csv Below the snippet code with File path Firewall settings checked no problem
int OnInit() { commonPath = TerminalInfoString(TERMINAL_COMMONDATA_PATH) + "\\Files\\"; string file_name = commonPath + FilePrefix + Symbol() + ".csv"; Print("=== TradeVisualizer Initialization ==="); Print("Target file: ", file_name); if(!FileIsExist(file_name)) { Print(" File does not exist: ", file_name); Print("Please ensure the CSV file is in the correct location."); return INIT_FAILED; } int handle = FileOpen(file_name, FILE_READ|FILE_CSV|FILE_ANSI|FILE_SHARE_READ, ','); if(handle == INVALID_HANDLE) { int error = GetLastError(); Print(" Cannot open file: ", file_name); Print("Error code: ", error, " - ", ErrorDescription(error)); return INIT_FAILED; } Print(" File opened successfully. Size: ", FileSize(handle), " bytes");
string file_name = commonPath + FilePrefix + Symbol() + ".csv";
File Write Problem (Error: 5002) - Expert Advisors and Automated Trading - MQL5 programming forum #1-2 (2020)
and FolderDelete using TERMINAL_DATA_PATH - General - MQL5 programming forum (2017)
"File does not exist: C:\Users\pc\AppData\Roaming\MetaQuotes\Terminal\Common\Files\TradeVisualizer_XAUUSD.csv Below the snippet code with File path Firewall settings checked no problem
Don't use an explicit full path with the FileOpen or FileIsExist functions. They are sandboxed, so use relative paths instead.
Also, if it is in the "Common" folder, then use the "FILE_COMMON" flag.
Please read the documentation for more details.
- 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 everyone,
My MQL5 indicator is supposed to import trade data from a CSV file and display them on the chart. The CSV file is properly exported and placed in the Terminal/Common/Files folder, but the indicator keeps returning error 5002 saying the file doesn't exist. The file is definitely there, what could be causing this file access problem?
Thanks!