MQL4 - automated forex trading   /  

Forum

File Write Question

Back to topics list To post a new topic, please log in or register

avatar
80
Yellowbeard 2010.04.20 05:40 


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!

Show Must Go On, or Once Again about ZigZag

Show Must Go On, or Once Again about ZigZag

About an obvious but still substandard method of ZigZag composition, and what it results in: the Multiframe Fractal ZigZag indicator that represents ZigZags built on three larger ons, on a single working timeframe (TF). In their turn, those larger TFs may be non-standard, too, and range from M5 to MN1.


avatar
Moderator
2030
gordon 2010.04.20 06:06 
You need to save the file handle returned by FileOpen() and pass that handle to FileWrite() and FileClose():
// ...
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:


avatar
80
Yellowbeard 2010.04.20 06:23 
gordon wrote >>
You need to save the file handle returned by FileOpen() and pass that handle to FileWrite() and FileClose():
Day() will be automatically cast to string when passed to FileOpen(), there is no need to use DoubleToStr().


Next time:


Thanks, Gordon!

Worked like a charm!

Yellowbeard
Back to topics list  

To add comments, please log in or register