What MQL4 error 5004 means
The official MQL4 runtime table names error 5004 ERR_FILE_CANNOT_OPEN and defines it as “cannot open file.” FileOpen returned INVALID_HANDLE because MT4 could not open the requested file under its file sandbox and access flags.
An error-state value is supporting context, not proof that a call failed or a diagnosis of the whole EA. For noncritical API failures, read the return value and then GetLastError, which resets _LastError. Critical errors such as zero division terminate execution, so code after the failing expression cannot serve as a recovery handler.
