Loading…

Pair Divergence Alert Matrix

A single-pair correlation-break alert only watches one relationship at a time. This extends the same idea across a whole watchlist at once: every symbol is compared against every other symbol in a grid, and each cell shows that specific pair's recent correlation, colour-coded against ITS OWN baseline rather than a single fixed threshold applied to everyone. The reason this matters: different pairs sit at very different normal correlation levels to begin with. EURUSD and GBPUSD might normally run around 0.80; EURUSD and USDJPY might normally sit near -0.30. A flat "alert below 0.30" rule would constantly fire on the second pair and never fire on the first even when it genuinely breaks down. Comparing recent correlation against each pair's own baseline window catches the actual regime change - a relationship moving away from what is normal FOR IT - rather than restating a static threshold everyone can already read off any correlation matrix. The panel rescans on a timer rather than every tick, since recomputing every pair's correlation on every incoming tick across a full watchlist would be wasteful and would also repeatedly re-trigger MQL4's background history-load for any watched symbol whose data has not fully synced. Notes and limitations - Both correlation windows are recomputed from scratch on every rescan, not tracked incrementally - the honest way to avoid drift, at the cost of a rescan taking proportionally longer as the watchlist and windows grow. - A cell shows "n/a" if either symbol's history is too short for the requested window, or if either return series is degenerate (zero variance) - never a fabricated correlation. - Correlation is measured on simple period returns of the chart's own timeframe, not resampled to daily bars, so a lower timeframe chart measures a shorter- duration relationship than a daily chart with the same bar-count inputs. - This is a snapshot panel refreshed on a timer, not a plotted historical series - it always reflects the most recent rescan, not the state at any earlier point the chart is scrolled back to. - Purely descriptive of what already happened; it does not predict whether a diverged pair will re-converge or stay broken.

Indicator · MT4 · v1.0 · Free

About Pair Divergence Alert Matrix

Pair Divergence Alert Matrix is an indicator for MetaTrader 4 based on Divergence. It can alert you with a pop-up, sound, email or push message. It has 11 settings, such as Watchlist, Symbol suffix and Recent window. MQL source code included.

Files in the download: PairDivergenceMatrix.mq4, PairDivergenceMatrix.txt.

Settings

SettingDefaultWhat it does
WatchlistEURUSD,GBPUSD,USDJPY,USDCHF,AUDUSD,USDCAComma-separated symbols (matrix rows/cols)
Symbol suffixBroker suffix appended to every symbol, leave blank if none
Recent window20Trailing closed bars the RECENT correlation is measured over
Baseline window100Trailing closed bars the BASELINE correlation is measured over
Divergence alert0.50Flag a cell when (baseline - recent) correlation reaches this
Refresh seconds30Seconds between automatic rescans
AlertstrueAlert once per rescan when a NEW pair crosses into divergence
CornerCORNER_LEFT_UPPERPanel corner
X10Panel horizontal offset, pixels
Y20Panel vertical offset, pixels
Font size8Grid cell font size

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 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: Grid · Divergence · Alerts · MT4 Indicator · MQL4 Source Code

MetaTrader 4 & 5 indicators · PolyMaria