Loading…

Lead-Lag Cross Correlation

A plain correlation number at lag zero only answers whether two symbols move together right now - it says nothing about which one moves first. This indicator scans a whole range of lags either side of zero, correlating one symbol's return now against the other symbol's return from each candidate lag in the past, and reports the lag where that correlation peaks. A peak away from zero means one instrument's recent move tends to precede the other's, which is a genuinely different, and often more tradeable, fact than simple co-movement. The panel lists every scanned lag with its correlation as both a number and a small diverging bar, the peak lag highlighted, and a one-line plain-English summary naming which symbol leads and by how many bars - or stating plainly that no lag cleared the significance threshold, rather than reporting a noisy peak as if it were meaningful. Getting the sign of "leads" backwards is the easy mistake here, so the convention is fixed and stated once: a peak at positive lag N means the SECOND symbol's return from N bars ago best explains the chart symbol's return now - the second symbol leads. A peak at negative lag means the chart symbol leads instead. The summary line always spells this out by name rather than leaving the sign to be interpreted. Notes and limitations - Both symbols are read at the chart's own timeframe; the lag axis is therefore in units of that timeframe's bars, not a fixed time unit - a lag of 3 means three H1 bars on an H1 chart, three M5 bars on an M5 chart, and so on. - The scan only re-runs once per newly closed bar, not every tick, since a lag scan over closed history cannot meaningfully change within the same still-forming bar. - A lead-lag relationship measured this way is a backward-looking statistical pattern, not a mechanism - it can be genuine (one market opens before another) or coincidental, and can change or vanish without warning around news events. - No alerting in this version; the scan is meant to be read as a snapshot each time it refreshes, not treated as a trade trigger by itself.

Indicator · MT5 · v1.0 · Free

About Lead-Lag Cross Correlation

Lead-Lag Cross Correlation is an indicator for MetaTrader 5. It has 11 settings, such as Second symbol, Symbol suffix and Lookback bars. MQL source code included.

Files in the download: LeadLagCrossCorrelation.ex5, LeadLagCrossCorrelation.mq5, LeadLagCrossCorrelation.txt.

Settings

SettingDefaultWhat it does
Second symbolGBPUSDSecond symbol (the chart's own symbol is the first)
Symbol suffixBroker suffix appended to InpSecondSymbol, leave blank if none
Lookback bars120Bar-to-bar returns used per correlation at each lag
Max lag bars10Scans lags from -InpMaxLagBars to +InpMaxLagBars
Significance level0.30|r| below this at the peak lag is reported as "no clear relationship"
CornerCORNER_LEFT_UPPERPanel corner
X distance10Panel horizontal offset, pixels
Y distance20Panel vertical offset, pixels
Font size8Row font size
Row height13Row height, pixels
Bar width120Maximum pixel width of the correlation bar at |r| = 1

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria