Try as follows.
int handle1; int handle2; string name1 = "ABC.csv"; string name2 = "XYZ.csv";
int myfunction(string name) { int handle = FileOpen( name, FILE_CSV | FILE_READ | FILE_WRITE, ','); return(handle); }
handle1 = myfunction(name1); handle2 = myfunction(name2);
Yes it's the smart way of doing it
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
I want my indicator to open and write to 2 files but the indicator opens and writes only to the first file.
I use the names and handles like this to write and open the file.
First I define variables in the global scope:
then I define my function :
but I think FileOpen returns the number +1 to both Handle1 and Handle2, and then MT4 gets confused.
Then I call the function in OnCalculate
the result is that only the file1 with name1 is created and filled with data.
File2 with name2 is never created.
If I do not pass the handle by reference, ie NOT doing this
int & handle,
but only this
int handle,
then the terminal says it can't open or create the first file...