Last Thursday, I sat down to run a quick optimization on a Grid EA I had been working on. I fired up the Strategy Tester, selected EURUSD, set the date range to last year, and hit Start. The journal returned a single line: "No data for this symbol/period." The chart was empty. Not a single candle.
My first thought was, "Did I forget to download the history?" So I went to Tools > Options > Charts and clicked the "Export" button to grab the latest 1-minute data from the MetaQuotes server. The download finished, but the tester remained blank. I restarted MT4. Still blank. That was the moment I realized this wasn't a simple download issue but a data corruption problem.
Here's the thing most people miss: MT4 stores historical data in
.hst files inside the history\[BrokerName] folder. If that file gets corrupted due to an abrupt terminal shutdown or a bad data packet, the tester will refuse to read it even though the file exists. Deleting the corrupted file manually forces MT4 to rebuild it from the server—but only for the current timeframe. If you have a corrupted 1-minute base, the higher timeframes built from it will remain empty.The official MQL4 documentation on File Functions mentions
FileOpen, FileWrite, and FileRead, but it does not cover how to rebuild tick-level data from scratch. I had to develop a practical workaround.My exclusive insight here is that MT4's backtester actually relies on the 1-minute
.hst data to generate ticks for the "Every Tick" modeling mode. If the 1-minute data is incomplete, the tick generator has nothing to interpolate. However, you can force the terminal to reconstruct missing data by running a custom MQL4 script that writes synthetic 1-minute bars from the highest available timeframe, then re-exporting the history.Here is the step-by-step process I followed to fix it:
C:\Users\[YourUsername]\AppData\Roaming\MetaQuotes\Terminal\[TerminalID]\history\[BrokerName]\. Cut the EURUSD1440.hst (daily) and EURUSD1.hst (1-minute) files to a backup folder. Do not delete them immediately; just move them out.FileOpen and FileWrite functions with the FILE_BIN flag. The script checks the last timestamp and, if there is a gap, backfills using the previous close.``
cpp
// Simple backfill logic for missing bars
int handle = FileOpen("EURUSD1.hst", FILE_BIN|FILE_WRITE|FILE_READ);
if(handle != INVALID_HANDLE) {
// Custom write logic here
FileClose(handle);
}
``Reference: MQL4 Documentation - Working with Files (docs.mql4.com), MetaQuotes Help Center - Data Export.
This article was originally published on FXEAR.com. All rights reserved. Unauthorized reproduction is prohibited.