What MQL4 error 5002 means
The official MQL4 runtime table names error 5002 ERR_WRONG_FILE_NAME and defines it as “wrong file name.” The file name or relative path passed to the file API is not valid for the MT4 file sandbox.
The error number is evidence about one failed call, not a diagnosis of the whole EA. Read the API sentinel first, then call GetLastError immediately because that function returns the current _LastError value and resets it.
