Skip to content
All library documents

Building a Multi-Timeframe Indicator with Recursion

Article MQL5 code base

Summary

This brief example introduces a recursive structure for calculating an indicator across multiple timeframes. It separates the indicator’s calculation from the process that retrieves higher-timeframe data, so either part can be adapted independently. The calculation itself can be replaced, and the data retrieval approach could be extended to handle multiple symbols with suitable changes.

A later update reports a synchronization fix for higher-timeframe values and a change to use previous-bar closes. Using completed bars avoids the fluctuations that occur while the current bar is still forming. The document provides no formula for the indicator, performance results, or detailed implementation, so it serves as a structural overview rather than a complete strategy or guide to validating signals.

Key ideas

  • A recursive structure can organize calculations across multiple timeframes.
  • The indicator calculation can be separated from higher-timeframe data retrieval.
  • The data retrieval component may be adapted for multi-symbol use.
  • Using previous-bar closes can avoid signals changing with the still-forming bar.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.