expert advisor cannot open files but script can
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); }
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