[MQL5] CSV files get deleted once read in strategy tester?

 

In MT5 strategy test, the FileOpen() function deletes the files. 

Why is this happening and what is the solution, please?

 handle=FileOpen(FileName,FILE_CSV|FILE_READ,',');
 
OrangeTrading:

In MT5 strategy test, the FileOpen() function deletes the files. 

Why is this happening and what is the solution, please?

FileOpen() doesn't delete files, they are delete automatically.

You have to use #property tester_file. See documentation.

 
Alain Verleyen:

FileOpen() doesn't delete files, they are delete automatically.

You have to use #property tester_file. See documentation.


Thanks for your info.

So in my case to maintain the file "data.csv" I add:


#property tester_file "Data.csv"


But then I still see the file being deleted. What am I doing wrong?

 
OrangeTrading:

Thanks for your info.

So in my case to maintain the file "data.csv" I add:



But then I still see the file being deleted. What am I doing wrong?

You didn't do anything wrong. As I said it's deleted automatically.

You need to use #property°tester_file, so it will be copied (automatically) again when needed.

What's the problem ?

 
Alain Verleyen:

You didn't do anything wrong. As I said it's deleted automatically.

You need to use #property°tester_file, so it will be copied (automatically) again when needed.

What's the problem ?

Hi there,


I also need some help with this automatically file being deleted. How do I use #property°tester_file in order to copy the file I need?


I created a csv file wich is erased every time I run the EA, so I'd like to keep this file in folder.

 
Ian Frazão:

Hi there,


I also need some help with this automatically file being deleted. How do I use #property°tester_file in order to copy the file I need?


I created a csv file wich is erased every time I run the EA, so I'd like to keep this file in folder.


Hello,

Did anyone get a definitive answer to this question.  The documentation is unclear.  I use the #property tester_file and still the file gets deleted from 

the directory every time I run the strategy tester.  Clearly the file is in the right place because it gets read and deleted.  However, I cannot be sure that

the file to be copied by the system is in the correct place, other than that it is in MQL5/Files as it is when I run the EA on a chart normally.  Other that this

I have no idea.  Any assistance appreciated.

Thanks

Jeff

 

Just add a comment here for future references as some random person happens to google this.

The document sucks at this part. I have used the 

#property tester_file "testfile"

And it just does not work.

I suggest the easier solution:

Place your file in the: "%AppData%\MetaQuotes\Terminal\Common\Files" . If you do not see the folder "Files" in "%AppData%\MetaQuotes\Terminal\Common" then create one first. 

Anyway, once you have done so, to interact with files, use "File Common", like this:

int h=FileOpen("test.txt",FILE_READ|FILE_ANSI|FILE_TXT|FILE_COMMON);

The files in the "Files" common folder won't even get deleted.

 

For some reason, this is what works now at year 2022 

int h=FileOpen("test.txt",FILE_READ|FILE_ANSI|FILE_COMMON);

with FILE_TXT removed