I'm not sure FileOpen will create a file... the dictionary doesn't indicate if it will create a new file if it can't find an existing file... and there is no FileNew() function....
""Opens file for input and/or output. Returns a file handle for the opened file. A return value less than 1 indicates an error.
Note: Files can be opened only from MetaTrader_dir\experts\files directory and it's subdirectories. ""
Try creating a "mydata.csv" file with a text editor and see if it opens it...
d
""Opens file for input and/or output. Returns a file handle for the opened file. A return value less than 1 indicates an error.
Note: Files can be opened only from MetaTrader_dir\experts\files directory and it's subdirectories. ""
Try creating a "mydata.csv" file with a text editor and see if it opens it...
d
I tried different things including your suggestion. It doesn't work. I also tried to qualify the filename with the pathname. Still no luck.
Just add FILE_WRITE mode.
int start() { int hnd; //---- hnd=FileOpen("mydata.csv", FILE_CSV|FILE_WRITE,";"); if(hnd<0) { Comment("Unable to open file my_data.csv"); return(0); } FileWrite(hnd, Close[0], Open[0], High[0], Low[0]); FileClose(hnd); //---- return(0); }
Renat,
Did you really try it? I cann't still get the file created or opened. The FileOpen() function returns -1. To avoid mistakes, I cut & pasted your code as is. I have no luck.
Thanks.
Did you really try it? I cann't still get the file created or opened. The FileOpen() function returns -1. To avoid mistakes, I cut & pasted your code as is. I have no luck.
Thanks.
in our dictionary sample written
===
handle = FileOpen("my_data.dat",FILE_CSV|FILE_READ,";");
===
insert back FILE_READ mode please.
and we well check once more default mode
===
handle = FileOpen("my_data.dat",FILE_CSV|FILE_READ,";");
===
insert back FILE_READ mode please.
and we well check once more default mode
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
Code:
int h1;
h1 = FileOpen("mydata.csv", FILE_CSV, ";");
if(h1<0)
{
Comment("Unable to open file my_data.csv",h1);
return(false);
}
Output: Unable to open file my_data.csv -1
(Of course mydata.csv is not created).