Read a csv file from the strategy tester

 

Hello,

I'm trying to read a value from a csv file. Everything works fine  when I attach the EA on a chart. The problem is only with the strategy tester.

As per the documentation : The file is opened in the folder of the cli ent terminal in the subfolder MQL5\files (or testing_agent_directory\MQL5\files in case of testing).

I tried to put the files in AppData\Roaming\MetaQuotes\Terminal\XXXXXXXXXXXXXXXX\Tester\Files or AppData\Roaming\MetaQuotes\Terminal\XXXXXXXXXXXXXXXX\testing_agent_directory\MQL5\files but I always got the same error (error code 5004).

I also use the following directive in mycode :

#property tester_file "testfile"


Obviously there is something that I don't understand.

My question is what or where is  testing_agent_directory\MQL5\file directory. 

Can someone help me locate the folder please

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 

Hi,

Finally, I found  the good path for the file by using this

TerminalInfoString(TERMINAL_DATA_PATH)

I find that there is a lot of lack in the MQL5 documentation or it is not intuitive. Hope this can help

https://www.mql5.com/en/docs/check/terminalinfostring

Documentation on MQL5: Checkup / TerminalInfoString
Documentation on MQL5: Checkup / TerminalInfoString
  • www.mql5.com
TerminalInfoString - Checkup - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

hi, 

i have same problem!!! But did not resolved with your help

 
Jabir Ismaeili #:

hi, 

i have same problem!!! But did not resolved with your help

I found the location by looking in the tester log file in the terminal files area:
...\AppData\Roaming\MetaQuotes\Terminal\....\Tester\logs\20241116.log

with a line near the end of:
log file "...\AppData\Roaming\MetaQuotes\Tester\....\Agent-127.0.0.1-3000\logs\20241116.log" written

which gave me the path for Files in the tester as
...\AppData\Roaming\MetaQuotes\Tester\....\Agent-127.0.0.1-3000\MQL5\Files

and when I put the files I wanted to open under that directory it worked EXCEPT that the files were deleted after a run.

Why should I have to copy my files for every test run?

A better solution is required please.
 
AutoAbacus #:
I found the location by looking in the tester log file in the terminal files area:
...\AppData\Roaming\MetaQuotes\Terminal\....\Tester\logs\20241116.log

with a line near the end of:
log file "...\AppData\Roaming\MetaQuotes\Tester\....\Agent-127.0.0.1-3000\logs\20241116.log" written

which gave me the path for Files in the tester as
...\AppData\Roaming\MetaQuotes\Tester\....\Agent-127.0.0.1-3000\MQL5\Files

and when I put the files I wanted to open under that directory it worked EXCEPT that the files were deleted after a run.

Why should I have to copy my files for every test run?

A better solution is required please.
Update. My input files were deleted by the tester only when the test tun ended abnormally on an error condition. They remained in place when the test run completed normally.

But why are they being deleted at all?
 
AutoAbacus #:
Update. My input files were deleted by the tester only when the test tun ended abnormally on an error condition. They remained in place when the test run completed normally.

But why are they being deleted at all?
Ah the better or easier anyway solution is to put the file or files to be read in the common files area and then use FILE_COMMON when opening the files,
as per "Open Files during backtest" and several posts there. Reading files there works when running normally or via the tester with no changes required.

Use of "#property  tester_file" is also possible but use of the common files area seems simpler and easier.
Open Files during backtest - How to make file referencing easy.
Open Files during backtest - How to make file referencing easy.
  • 2018.05.16
  • chinaski
  • www.mql5.com
Ok, after some research, i found the property tester_file. When disable #property, still not working. Of course you need to tester_file directive. Thank you but i did this and it is was working. Now restarting or next day and it works