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 · MT4 · v1.0 · Free
About Lead-Lag Cross Correlation
Lead-Lag Cross Correlation is an indicator for MetaTrader 4. It has 11 settings, such as Second symbol, Symbol suffix and Lookback bars. MQL source code included.
Files in the download: LeadLagCrossCorrelation.ex4, LeadLagCrossCorrelation.mq4, LeadLagCrossCorrelation.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Second symbol | GBPUSD | Second symbol (the chart's own symbol is the first) |
| Symbol suffix | Broker suffix appended to InpSecondSymbol, leave blank if none | |
| Lookback bars | 120 | Bar-to-bar returns used per correlation at each lag |
| Max lag bars | 10 | Scans lags from -InpMaxLagBars to +InpMaxLagBars |
| Significance level | 0.30 | |r| below this at the peak lag is reported as "no clear relationship" |
| Corner | CORNER_LEFT_UPPER | Panel corner |
| X distance | 10 | Panel horizontal offset, pixels |
| Y distance | 20 | Panel vertical offset, pixels |
| Font size | 8 | Row font size |
| Row height | 13 | Row height, pixels |
| Bar width | 120 | Maximum pixel width of the correlation bar at |r| = 1 |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: MT4 Indicator · MQL4 Source Code