Fix your code or check that your file isn't open with an other application.
#property tester_file "access.log" //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- create timer EventSetTimer(1); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- destroy timer EventKillTimer(); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ //| Timer function | //+------------------------------------------------------------------+ void OnTimer() { //--- int fhandle = FileOpen("access.log",FILE_READ,""); if(fhandle!=INVALID_HANDLE) { Print("File opened !"); FileClose(fhandle); } else { printf("File open error #%i",_LastError); } EventKillTimer(); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register

Hi!
I'm trying to open a .txt file using CFileTxt class while executing backtesting. The idea is that it gets a list of datetime values which the EA is supposed to skip.
When trying to open the file, I allways get error 5004, so apparently the FileOpen function is not finding my .txt file. The problem is that I've tried to put it everywhere and it doesn't matter where I put it, it doesn't find it:
- Inside the "Files" folder in the data directory (MQL5/Files)
- Inside the "Tester" folder (installation id/Tester)
- Inside a "Files" folder inside there (installation id/Tester/Files)
- Getting the info of TerminalInfoString(TERMINAL_DATA_PATH), where the backtest agent is located
- Inside a "MQL5" folder created there
- Inside a "MQL5/Files" folder created there
- Inside a "Files" folder created there
- Inside the "Tester" folder where there is the list of tester agents
- Inside a "Files" folder created there
I found this link where mr. Alain suggested using thein the EA (and the helper files do indeed say files that are going to be used in backtesting must be informed with this property: "Input files to be tested, if needed, should always be specified."), but nothing changed.
So why exactly is this happening? I remember facing the exact same problem before and ended giving up and using the COMMONS file path. I'd like, though, to finally solve this issue. The only "appearence of solution" I found was this post , but using Windows functions to copy a file into a folder seems akward to say the least.
Finally, the "nothing special code":