If you will look into documentation of FileExist function you will find:
For security reasons, work with files is strictly controlled in the MQL4 language. Files with which file operations are conducted using MQL4 means, cannot be outside the file sandbox.
If common_flag = FILE_COMMON, then the function looks for the file in a shared folder for all client terminals \Terminal\Common\Files, otherwise the function looks for a file in a local folder (MQL4\Files or MQL4\Tester\Files in the case of testing).
It seems that FileExist finding files in only specified folders.
If you will look into documentation of FileExist function you will find:
For security reasons, work with files is strictly controlled in the MQL4 language. Files with which file operations are conducted using MQL4 means, cannot be outside the file sandbox.
If common_flag = FILE_COMMON, then the function looks for the file in a shared folder for all client terminals \Terminal\Common\Files, otherwise the function looks for a file in a local folder (MQL4\Files or MQL4\Tester\Files in the case of testing).
It seems that FileExist finding files in only specified folders.
Janusz - thank you
I had seen this but didn't really understand so have tried both of the following and get the same result - i.e. not found
Do you understand that I can NOT access this file location
(the 5002 error suggests a name error but could obviously mean the path - I guess)
if ( FileIsExist(myfile_name_and_path,1) )
You should only pass filename (not full path) for FileIsExist function. You can't check/find files in folder other than those mentioned in documentation.
If you need to search/check files in other folder, you need to use WinAPI functions.
Peter, MetaTrader allows to access only files from the folder "MQL5\files" (or testing_agent_directory\MQL5\files in case of testing).
Any other files are not accessible from EA or scripts because of security.
If you want to access the files outside MQL5\Files then you need to use WinAPI functions like Janusz told.
Peter, MetaTrader allows to access only files from the folder "MQL5\files" (or testing_agent_directory\MQL5\files in case of testing).
Any other files are not accessible from EA or scripts because of security.
If you want to access the files outside MQL5\Files then you need to use WinAPI functions like Janusz told.
Peter, MetaTrader allows to access only files from the folder "MQL5\files" (or testing_agent_directory\MQL5\files in case of testing).
Any other files are not accessible from EA or scripts because of security.
If you want to access the files outside MQL5\Files then you need to use WinAPI functions like Janusz told.
This is MQL4, so are not likely to find in MQL5 folders

- 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 the following error in my own log file.
My_error: 5002 wrong file name My_FileRead_Handle =0, fname = C:\Users\user\AppData\Roaming\MetaQuotes\Terminal\9ACB2E2CE0389240C909714389C79575\logs\20161108.log
The file appears to be where I think it should be and the error occurs when I use the FileExists statement
fname above is put together using code below where is this case fname starts as 20161108
fname = terminal_data_path+fname+".log";
I've spent quite sometime trying to locate this file - any ideas (I want to find a 'signal' in the log issued by an indicator)