Preparing Timeseries Data and Events for MQL5 Indicators
Summary
This installment explains how a library of timeseries objects can supply data to MetaTrader indicators. Its central concern is that indicators run in a symbol-specific execution stream and must not block while historical data is being downloaded or constructed. Unlike an EA or script, an indicator’s data-copy request can return immediately with no data while the terminal starts loading history. A later calculation call may find some or all of that history available. The indicator should use its own rates and calculation counters for the chart’s symbol and period rather than requesting that same series independently.
The article describes changes to library classes for indicator use, including availability and event flags, checks that prevent trading operations in indicators and services, and initialization of requested series. It reports that tests progressively created series, synchronized them, populated available bars, and delivered new-bar events; a tester visual run behaved as expected for used timeframes. These results demonstrate the described data-loading workflow, not a trading strategy or performance advantage. Indicator authors still need to handle incomplete history, synchronization, and repeated calculation calls without slowing other indicators on the same symbol.
Key ideas
- Indicator data requests may return before historical series are ready, with loading continuing asynchronously.
- Later OnCalculate calls can use history that has since become available.
- Indicators should rely on rates_total and prev_calculated for their own chart series.
- Library classes are adjusted to initialize timeseries, signal updates, and avoid trading actions in indicator contexts.
- The reported tests show series synchronization and new-bar events, but provide no strategy-performance evidence.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.