Building a Weekday-Hour Heatmap of Average Intraday Returns in MQL5
Summary
The document explains how to build an MQL5 heatmap that summarizes average bar returns by weekday and hour. It defines each bar’s percentage return from consecutive closes, excludes weekend bars, and aggregates observations into a five-by-twenty-four grid. Each cell’s arithmetic mean is mapped to a color from red through gray to green, with intensity scaled against the largest absolute average in the grid. The described implementation separates timestamp analysis, data accumulation, statistics, color selection, and canvas rendering.
The article illustrates the output with a EURUSD H1 example using 5,000 historical bars and gives diagnostic ranges and rendered-cell counts. It also explains that the historical scan grows with the lookback size, while rendering has a fixed workload. The heatmap is an exploratory description, not a predictive signal: markets can change, and the indicator does not test statistical significance. In particular, cells with few observations may show unstable averages, and the same lookback covers very different spans of time on different chart intervals.
Key ideas
- Bar returns are calculated as percentage changes between consecutive closes to make values comparable across instruments.
- Each valid observation is assigned to one weekday-hour cell, where the indicator computes an arithmetic mean.
- A red-to-green color scale represents negative to positive averages, normalized by the strongest absolute cell value.
- The scan cost depends on the number of historical bars, while grid rendering uses a fixed number of cells.
- Historical patterns are descriptive; low sample counts and changing market conditions limit their use as forecasts.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.