Discussing the article: "Integrating MQL5 with Data Processing Packages (Part 11): Multi-Timeframe Causality Detection using Granger Analysis"

Check out the new article: Integrating MQL5 with Data Processing Packages (Part 11): Multi-Timeframe Causality Detection using Granger Analysis.

This article implements a multi‑timeframe Granger causality monitor for MetaTrader 5. A Jupyter notebook tests predefined timeframe pairs, selects lags, applies multiple‑testing control, and exports a calibration table. An MQL5 Expert Advisor reloads the setup, recomputes the F‑test live on rolling windows, and marks pairs VALID/INVALID to gate its vote‑based BUY/SELL generator. The workflow shows alignment rules, live/offline parity, and a filtered vs unfiltered comparison on EURUSD.

Most multi-timeframe setups rest on an assumption nobody checks: that the higher timeframe tells the lower timeframe something useful. We put an H1 trend filter on an M15 entry, or require M30 and M5 to agree, and move on. Whether the H1 bars actually carry information about the next M15 bar, beyond what the M15 bars already know about themselves, is rarely tested. If that relationship is weak, the extra timeframe is just another condition that cuts trades without improving them. If it is strong only some of the time, a fixed rule will be right in one regime and quietly wrong in the next.

Granger causality is a direct way to test this. The idea is simple: if the past values of series X improve the forecast of series Y beyond what Y's own past already provides, then X "Granger-causes" Y. It says nothing about real-world cause and effect, only about predictive content, and that is exactly the question a trader should ask about a higher timeframe. We run this test in Python, where the statistics tools are mature and easy to cross-check, then carry the result into MQL5 where a simplified version of the same test is recomputed on live data and used as a gate for signals.

Author: Hlomohang John Borotho