Discussing the article: "Detrended Cross-Correlation Analysis (DCCA) for Pairs-Trading Pair Selection Under Nonstationarity"

Check out the new article: Detrended Cross-Correlation Analysis (DCCA) for Pairs-Trading Pair Selection Under Nonstationarity.

A complete, native MQL5 toolkit for Detrended Cross-Correlation Analysis: engine, validator, basket scanner, and a reference spread-trading EA. The engine produces a scale-by-scale rho_DCCA(s) curve and a band-mean score to rank pairs, contrasted with a standard Pearson correlation. The article details the box-detrending approach and shows real Strategy Tester results to illustrate how the gate integrates into trade decisions.

Pairs trading starts with a question that sounds simple and usually isn't: which two instruments actually move together? The standard answer is a Pearson correlation over some lookback window, fine for a short window on a well-behaved pair. The trouble starts with instruments that trend — gold against silver over a quarter where both have been climbing, or a Tokyo-session cross against a London-session one with a visible drift in each.

The Pearson coefficient is computed the same way regardless; what changes is how to read it. A level-to-level correlation between two independently trending series can come out high even when the trends have nothing to do with each other — two unrelated upward drifts covary with the calendar, not one another — so a high reading doesn't by itself mean the instruments are related at the time scales that matter for trading them as a pair.

Detrended Cross-Correlation Analysis (DCCA) was built for exactly this case: it correlates what's left after a local trend has been removed from each series, at a chosen scale. Repeating that across several scales turns one correlation number into a curve — how related are these two instruments over 10 bars, over 50, over 200? A pair can be weakly related at a scalper's scale and strongly related at a swing trader's, and DCCA shows that difference instead of averaging it away.

This article builds a native MQL5 implementation of DCCA (no DLLs, no ALGLIB — just matrices/vectors and loops), then uses it to rank candidate pairs by scale-dependent correlation instead of a single Pearson number, and to gate a simple mean-reversion spread trade. Every figure in the Testing section comes from real MetaTrader-history runs, including losing ones — a correlation tool can be useful even when the trading rule built on it isn't, and this article says plainly which of the two it demonstrates.

DCCA works on the cumulative, de-meaned profile of each series rather than the raw series itself. For a series x of length n:

Author: Bosede Gbadebo