If you are doing this inside the tester, the file location is a different one. There are special folders for the testers "personal" files. Try placing it inside the common folder.
Another hint, Resetlastterror () should be after Print().
Print() requires you to have more than just a static input, else it will set an error code.
Dominik Egert:
If you are doing this inside the tester, the file location is a different one. There are special folders for the testers "personal" files. Try placing it inside the common folder.
Another hint, Resetlastterror () should be after Print().
Print() requires you to have more than just a static input, else it will set an error code.
Thanks for the tips!
I moved the file to my MetaQuotes\Terminal\Common\Files\Riskarray. I am getting error 5004. Is there a way to specify that the EA needs to look for files in the common folder?
Forum on trading, automated trading systems and testing trading strategies
expert advisor cannot open files but script can
aseedb, 2021.06.27 11:41
Thanks for the tips!
I moved the file to my MetaQuotes\Terminal\Common\Files\Riskarray. I am getting error 5004. Is there a way to specify that the EA needs to look for files in the common folder?
Problem solved! I needed to add the FILE_COMMON flag.
int OnInit() { //--- double myarray[]; string path="RiskTables\\drawdown_6percent_focused_x.bin"; Print("we are going to open the file"); ResetLastError(); int handle=FileOpen(path,FILE_READ|FILE_BIN|FILE_COMMON); if(handle!=INVALID_HANDLE) { FileReadArray(handle,myarray); int size=ArraySize(myarray); int step = size/10; for(int i=0;i<size;i=i+step) Print(myarray[i]); //--- close the file FileClose(handle); } else Print("Failed to open the file, error ",GetLastError()); FileClose(handle); //--- return(INIT_SUCCEEDED); }
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 have a binary file containing an array and my expert advisor needs to read it. However, I can't get it to open the file. I can open it with a script though. I think that the expert advisor is not looking for my file in the same folder as the script. I have put it in data_folder/MQL5/Files/RiskTables/
Here is the code of the script that is working:
As expected I get numbers in the alert pop up window.
And the expert advisor code, which is not working is:
Here I am getting this output:
Any piece of advise will be highly appreciated.
Benoit