when i place a file into folder files i can open this file when running or debug my expert.
But when i run the backtest, the file is not found.
Ok, after some research, i found the property tester_file.
When i add this to my code:
#property tester_file "my_file_name_with_relative_path_to_files"
The backtest can open the file.
But when i run now the expert in debug mode or in chart, it works not.
When disable #property, still not working.
How to make file referencing easy ?
Why not simply allow to store or load files from Files section or everywhere (with admin rights.)
This is an ugly stumblestone.
Sorry, can't follow you. I have no cryptic data folder as i work with /portable runtime flag.
If have a folder A:
and folders B,..:
root/tester/agent_some_name_rule/MQL5/files (there are multiple of them)
When i do no backtest, the files are picked from A.
If i do backtest, they are picked from elsewhere but i don't know which of the various agent folder is important.
It seems the mentioned property can help but the it seems the expert is messed up when running not in backtest.
The link provided explains the folder structure in MetaTrader but not really why files are loaded
in different ways when done from backtest or not.
I just want to use some files for configuration. I need the same files in backtest as well as in live run.
Is this possible ? Thank you.
#property tester_file has nothing to do with live chart. Must be something else as you said it continues to be a problem even if you remove the directive.
Please show the relevant code.
this is my code in OnInit
string read_text_file(string xfn)
fn += xfn;
//--- additional variables
//--- read data from the file
//--- find out how many symbols are used for writing the time
//--- read the string
//--- print the string
content += str;
//--- close the file
PrintFormat("Failed to open %s file, Error code = %d",fn,GetLastError());
When running/debugging expert, not problem. File is loaded.
When running in backtest, it gives error 5004
2018.05.17 03:05:08.333 Core 1 2000.01.01 00:00:00 Failed to open subfolder\setup.txt file, Error code = 5004
Can you give some information please. How to use it exactly: my file is:
How to use the directive exactly ? Thank you
#property tester_file "subfolder\\setup.txt"
Thank you but i did this and it is was working. Now restarting or next day and it works. Whats going on.