Concept

Correlation

Correlation, also known as Pearson, Spearman, rolling, correlation matrix, is a Statistics concept. The Library holds 12 implementations, each one a working definition you can pull into Quant.

Top Correlation indicators

12 total

What is Correlation?

Correlation measures how consistently two series move together, on a scale from -1 to +1. The standard Pearson coefficient is the covariance of the two series divided by the product of their standard deviations: +1 means perfectly aligned moves, -1 perfectly opposite, 0 no linear relationship. The Spearman variant applies the same formula to ranks instead of raw values, which captures any monotonic relationship and blunts the effect of outliers. Traders usually compute it on returns over a rolling window, because raw trending prices produce inflated, spurious readings.

It matters because almost every multi-asset decision hides a correlation assumption: positions that look diversified but move together behave like one oversized trade, intermarket filters assume yesterday's relationships persist, and relative-value trades need co-movement to lean on. The honest caveats: correlation is unstable over time, says nothing about cause, and describes direction of co-movement only, not size. It also tends to rise sharply across risk assets in stress episodes, precisely when diversification is needed most.

How to calculate rolling correlation

Pearson correlation over a rolling window takes four steps, and the returns conversion in step one is the part that guards against spurious readings.

  1. 1Convert each series to returns or one-bar changes. Correlating raw prices overstates the relationship whenever both series trend, even if their day-to-day moves are unrelated.
  2. 2Choose a window N and, over the last N paired observations, compute each series' mean and its deviations from that mean.
  3. 3Multiply the paired deviations and sum them, then divide by the square root of the product of the two series' summed squared deviations. The result is the Pearson coefficient, bounded between -1 and +1.
  4. 4Plot the coefficient bar by bar as an oscillator. For Spearman correlation, replace the values in each window with their ranks first and apply the same arithmetic.

How traders use it

  • As a portfolio exposure check: highly correlated positions stack the same risk, so correlation feeds position sizing and concentration limits rather than entry signals.
  • As a directional filter: strategies condition entries on a driver series, for example trading a currency or index only when its rolling correlation with the dollar index or yields behaves the way the setup expects.
  • As the first screen for relative value: pairs traders shortlist highly correlated instruments, then test cointegration separately, because two assets can be tightly correlated bar to bar while their spread drifts apart indefinitely.
  • As a regime alarm: a rolling coefficient that collapses toward zero or flips sign flags that a historical relationship has broken, which matters most for hedges built on it.

Correlation vs related concepts

Beta: Correlation is unitless co-movement. Beta multiplies correlation by the ratio of the two volatilities to express how much one asset moves per unit move of the other, so two pairs can share a correlation of 0.9 while having very different betas.

Autocorrelation: Autocorrelation is a series correlated with its own past at some lag, a single-asset measure of persistence or mean reversion. Correlation as usually quoted compares two different instruments over the same bars.

Cointegration: Correlation describes short-run co-movement of returns; cointegration asks whether a combination of the price levels stays mean-reverting over the long run. Spread strategies need the latter, and high correlation alone does not deliver it.

More Correlation implementations

Related concepts · Relationships

Concept family

Statistics

45 concepts mapped · 37 in the Library

Correlation FAQ

Should correlation be calculated on prices or returns?

Returns. Price series trend, and two unrelated trending series can show a strong price correlation purely because both drift, a classic spurious-regression effect. Differencing to returns removes the shared drift so the coefficient reflects genuine bar-to-bar co-movement. Relationships between price levels themselves are better examined with cointegration tests.

What is the difference between Pearson and Spearman correlation?

Pearson measures linear association on the raw values, so a few outsized returns can dominate the estimate. Spearman converts each window to ranks first and measures whether the relationship is consistently monotonic. With fat-tailed financial data the two can disagree; Spearman is generally the more robust of the pair, at the cost of ignoring magnitudes.

How reliable are correlations over time?

Treat any figure as a snapshot. Rolling estimates drift with regimes, flip around macro events, and depend heavily on window length: short windows are noisy, long windows average over structurally different periods. Stress episodes are the sharpest failure mode, when correlations across risk assets tend to jump toward +1 and hedges calibrated on calm data disappoint.

Build Correlation your way.

Quant writes, tests, and refines it with you — then it runs on LuxAlgo charting or ports to TradingView.