History Downloader
The EA retrieves the quote history for the current chart symbol and timeframe by simulating a “Home button” press. This approach builds on the method used in the s-Downloader script by Talex (CodeBase link). The key distinction from s-Downloader is that only the bars belonging to the current timeframe are downloaded, up to a specified time. In my view this is more convenient, since I run tests on a single timeframe (the one I typically work with). In this version, the EA runs on a single start() iteration. That created some difficulties in obtaining the number of bars in the chart window and the time of the first bar. As a result, the EA pulls this data from global variables that are updated by the HistoryDownloader I indicator (included in the attachment). In fact, aside from updating the global variables, the indicator does nothing else 🙂 The attachment contains the EA (HistoryDownloader.mq4), the indicator (HistoryDownloader I.mq4) and an archive with both source codes plus compiled files (HistoryDownloader.zip). How to use all of that:
- Press Ctrl + O, check the maximum bars in history and on the chart;
- Open the chart window of the required symbol and select the TF for which the history is to be downloaded;
- Disable auto scroll and set the scale to minimum (“zooming out” as far as possible);
- Launch the HistoryDownloader I indicator on the chart;
- After that, launch the EA. EA parameters: datetime ToDate
- date up to which the quote history is downloaded int Timeout
- chart update waiting period, in milliseconds. The default is 1 second (1000) int MaxFailsInARow
- maximum number of consecutive unsuccessful attempts to “shift” the chart. The default is 10 I did my best to comment the code in detail. After all, this is my first publication in CodeBase.