I'm trying my hand at .hst files but without any success so far. After a few searches I came across this post https://forum.mql4.com/60455 where I got the file format from.
If I run the below lines the values are zero. Maybe the format has changed (I have build 765) or my code is wrong or both. I can't figure it out. I'm am trying to get to the end of the file, step back 60 bytes and read the bar info of the last available bar in the file. Any help would be welcome.
When I get this part right, I would like to change the bar info in the hst file. Does mql4 let you do that anyway without making it an off-line chart?
string hst_filename ="AUDCAD60.hst";
int hst_file = FileOpen(hst_filename, FILE_BIN|FILE_WRITE|FILE_READ);
datetime ctm = FileReadDatetime(hst_file);
double open = FileReadDouble(hst_file);
double high = FileReadDouble(hst_file);
double low = FileReadDouble(hst_file);
double close = FileReadDouble(hst_file);
long volume = FileReadInteger(hst_file);
int spread = FileReadLong(hst_file);
long real_volume = FileReadLong(hst_file);
IMHO the answer is no, you cannot make changes to hst file.
- You have to use negative numbers with SEEK_END: Print(FileSeek(hst_file,-60,SEEK_END));
- You have to add the sharing attributes to FileOpen. And even if you add them, you would realize, that they did not allow write access.
- the current MT4 uses weird file buffering, and even if you access the hst file on the drive for reading, the content might be obsolete.
To add comments, please log in or register