A thing that happens is a feature of the MQL4 ecosystem:
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.
The file is opened in the folder of the client terminal in the subfolder MQL4\files
( or Tester\Files
in case of testing ). If FILE_COMMON
is specified among flags, the file is opened in a shared folder for all MetaTrader 4 client terminals.
How to address this?
Simply, take care of using just the "relative" specification of the file-path ( and keep in mind, which of the three possible root-directory cases is being used in which modus-operandi ).
aFH = FileOpen( "aFileInsideDefaultDirectoryRoot.txt", ... );
//
// USED:
// in Strategy Tester---+
// plain EA-mode-----|------------+
// FILE_COMMON-mode--|------------|----------------+
// | | |
// RESULTS: v v v
// in a file in { tester\files | MQL4\Files | <shared_common_directory> }
For the case of reading the file, you might enforce to have a copy of the same configuration file in both of the locations for the non-FILE_COMMON
use-cases, or keep a single instance in <shared_common_directory>