Correlation Coefficient
By LuxAlgoApr 13, 2020
The Correlation Coefficient measures how consistently the chart symbol moves with a second, user-selected symbol, plotting the Pearson correlation over a rolling window as an oscillator bounded between -1 and +1. A reading near +1 says the two series rise and fall together; near -1, they move opposite ways; near zero, no stable linear relationship exists.
This build is the standard raw calculation: the chart symbol is compared against a comparison symbol input (the S&P 500 by default) over a 20-bar window, with an option to correlate log returns instead of raw prices. The Correlation line is drawn with a soft area fill, framed by dotted levels at +1, zero, and -1.
How to Trade the Correlation Coefficient?
- Near +1: the two symbols move in near-lockstep; holding both adds exposure, not diversification.
- Near -1: consistent opposite movement — the profile a hedge is supposed to have.
- Around zero: no dependable relationship; treat the pair as independent.
- Zero-line crosses: the sign has flipped; alert conditions cover crosses above and below zero.
- Drift from an extreme toward zero: a once-tight relationship is decoupling.
Correlation frames trades rather than triggering them: use it to size, filter, or veto ideas generated elsewhere.
Correlation Coefficient Settings
- Symbol (default SP:SPX): the instrument the chart symbol is measured against.
- Length (default 20): bars in the rolling window. Shorter reacts fast but whipsaws; longer is steadier but slow to register a real break.
- Source (default close): the price series used for both symbols.
- Use Log Returns (default off): correlates bar-to-bar log returns instead of raw values, stripping the trend effect that inflates raw-price readings.
Frequently Asked Questions
Should I correlate raw prices or log returns?
Log returns, for most decisions. Two instruments in long uptrends can post high raw-price correlation regardless of how their individual bars behave; Use Log Returns measures how the bars themselves move together instead.
How is the Correlation Coefficient different from beta?
Correlation grades the consistency of co-movement on a fixed -1 to +1 scale, but says nothing about size. Beta scales it: a stock can track an index tightly while moving twice as far on every swing — correlation captures the first fact and misses the second.
Does a high correlation make two symbols a good pairs trade?
Not by itself. Tightly correlated instruments can still drift apart indefinitely, so pairs traders use the coefficient as a first screen and test the spread separately. And the rolling 20-bar sample can swing hard — confirm on a longer Length before trusting it.
Free indicator
Get free access to this indicator on the platforms below.
The Library is free. Quant makes it yours.
Pull any concept or indicator into Quant: rebuild it, retune it, or turn it into a backtested strategy of your own.