Loading…

Two Symbol Correlation

Two instruments that both happen to be trending upward will show a misleadingly high correlation if you compare their raw price levels - the shared drift dominates the number even when the two symbols do not actually move together bar to bar. This indicator instead correlates bar-to-bar RETURNS, which strips the drift out and measures genuine co-movement: whether an up bar on one symbol tends to coincide with an up bar on the other, right now, over the chosen window. The result is the standard Pearson coefficient, bounded between -1 and +1. Values near +1 mean the two symbols have been moving together, values near -1 mean they have been moving opposite each other, and values near 0 mean little linear relationship over the current window. Because the window rolls forward one bar at a time, a pair that normally tracks tightly and has recently decoupled shows that as the line visibly dropping toward zero, rather than requiring the trader to notice it by eye on two separate charts. An optional alert can flag exactly that decoupling: when |correlation| falls below a chosen threshold after having been above it, useful for catching a normally-correlated pair (e.g. two commodity currencies, or a symbol against an index) starting to move independently. Notes and limitations - Both symbols are read at the same bar shift index, which assumes they share the chart's timeframe and closely aligned session hours - accurate for most forex pairs on the same broker feed, approximate when comparing across very different session hours or asset classes. - Correlation is a backward-looking descriptive statistic over the chosen window, not a forecast of future co-movement. - Values are computed strictly from closed bars (the window always ends one bar in the past relative to the bar being evaluated), so nothing plotted here repaints on a later tick. - If either symbol has too little history loaded for the requested window, the line is left empty rather than plotting a value built from a partial sample.

Indicator · MT5 · v1.0 · Free

About Two Symbol Correlation

Two Symbol Correlation is an indicator for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Second symbol, Symbol suffix and Lookback bars. MQL source code included.

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

Settings

SettingDefaultWhat it does
Second symbolGBPUSDSymbol to correlate against the chart symbol
Symbol suffixBroker suffix appended to InpSecondSymbol, leave blank if none
Lookback bars50Rolling window, in closed bar-to-bar returns
AlertsfalseAlert once per closed bar when |correlation| drops below InpAlertLevel
Alert level0.3|Correlation| threshold that triggers a decoupling alert

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: Trend · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria