You need to save the file handle returned by FileOpen() and pass that handle to FileWrite() and FileClose():
Next time:
// ... int handle = FileOpen(Day()+".csv", FILE_CSV|FILE_WRITE, ';'); // if... FileWrite(handle, DoubleToStr(PnvH,Digits)); FileClose(handle);Day() will be automatically cast to string when passed to FileOpen() so there is no need to use DoubleToStr(). You do need to use DoubleToStr() to write PnvH so as the correct number of digits are printed to file.
Next time:


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'm trying to store the HIGH of the day in a folder, who's name, is the day of the month. ( i.e 20 )
PnvH=iHigh(NULL,1440,0); // 1 Day High
OHday = DoubleToStr(Day(),0);
FileOpen(OHday, FILE_CSV|FILE_WRITE, ';');
if(StrToDouble(OHday)>0)
{Alert("OHday is: ",OHday," PnvH is: ",PnvH);
FileWrite(OHday, PnvH);
FileClose(OHday);}
Creating a file folder who's name is the day of the month is not my problem. My problem is that no matter what I do, the file is empty. No number. No string.
Can anyone see or tell me what I'm missing? It must have something to do with converting Double to String, then, String to Double. If I don't convert "OHday" to StrToDouble in the "if"
statement, I get a "Type Mismatch" error.
Thanks!