Correlation coefficient

Correlation
Indicator

StatisticalSeparate panelFree on ChartLabs

The correlation coefficient is the Pearson r of the close against time over the last 20 bars, from -1 to 1, showing how straight the recent trend has been.

Karl Pearson, 1896. Reviewed by the ChartLabs team, updated Nov 2026.

Example market1hIndicatorsAtlas AICorrelationchartlabs.co/charts
Atlas reads it

Correlation Coefficient is -0.958.

Correlation Coefficient -0.958

Atlas reads it

Correlation Coefficient is -0.958.

Correlation Coefficient -0.958

Illustration on simulated data.

Correlation coefficientWhat is the Correlation indicator?

Each bar, the indicator fits a straight line to the last 20 closes and reports how tight that fit is. The number is Pearson's r, not the slope and not a forecast. A perfect rise reads 1. A perfect fall reads -1. A flat window has no r, so the line is empty rather than zero.

Closes 1 through 20 are a perfect rise, so r is 1 on the bar where the 20th close arrives (record 19). Twenty closes of 5 have no variation, so r is empty. The length can be as short as 2. Until 20 closes exist, the value is empty.

The source defaults to the close. The line is blue #2196F3, 2 px, in its own panel, with 3 decimals. There is no second symbol: the correlation is with time, the bar number, not with another market.

Empty until 20

r needs a full window. Records before the length are empty, not zero.

With time, not with another symbol

There is no second instrument input. The x-axis of the fit is the bar count.

Correlation signalsFive patterns to know.

1Bullish lean

Near 1

The last 20 closes lie close to a rising straight line.

2Bearish lean

Near -1

The last 20 closes lie close to a falling straight line.

3Inconclusive

Near 0

The closes have little linear relationship with time. A bend or a chop both do this.

4Inconclusive

No value

The window is not full yet, or every close in it is the same.

5Inconclusive

Falling off 1

A rise that had been straight is bending. r drops before the slope has to change sign.

Correlation formulaHow it is calculated.

r=Σ(x−x¯)(y−y¯)Σ(x−x¯)2·Σ(y−y¯)2
STEP 1

Take the window

Use the last 20 closes. Before that, leave the line empty.

STEP 2

Fit time

Compare those closes with the bar numbers 0 through 19 inside the window.

STEP 3

Read r

A rise of 1, 2, 3 and on through 20 gives r of 1. Twenty equal closes give no r.

Correlation settingsEvery setting, explained.

SettingDefaultRangeWhat it changes
Length202 to 5,000How many closes are in the fit. The Signal lens changes this.
SourceCloseAny price, or volumeThe series correlated with time.
LineBlue #2196F3, 2 pxFixedOne line, 3 decimals, in its own panel.
Setting
Length
Default
20
Range
2 to 5,000
What it changes
How many closes are in the fit. The Signal lens changes this.
Setting
Source
Default
Close
Range
Any price, or volume
What it changes
The series correlated with time.
Setting
Line
Default
Blue #2196F3, 2 px
Range
Fixed
What it changes
One line, 3 decimals, in its own panel.
207 closes in the fit
70,20866,82563,44360,06164,803.7

Drag to see how the setting changes the lines and how many signals you get. Illustration on simulated data.

Correlation strategiesUse it in 3 setups.

A high r with the trend

Whilerstays near1

The recent closes have been a clean rise. Traders often want that before they treat a breakout as orderly.

r peeling off the extreme

Ifrfalls from near 1thenthe line fit is loosening

Price may still be up. The closes are no longer in a straight line.

Ignore the warm-up

Iffewer than 20 closes existthenthere is no r yet

An empty line is not a zero, and it is not a signal.

Test a rule in the Strategy TesterFree with 1 year of history. Past results do not guarantee future results.

Correlation mistakesCommon mistakes.

Reading r as a slope

r of 1 says the rise is straight. It does not say how many points per bar. A shallow line can also read 1.

Calling 0 a reversal

Near 0 means the window is not a straight line. It can be a range, a curve, or a mix.

Treating a flat market as r of 0

If every close is equal, r is undefined and the line is empty.

Correlation combinationsPair it with these.

Correlation FAQQuestions traders ask.

What are the correlation settings?

Length 20 and source close. There is no second symbol.

What does 1 mean?

The closes in the window sit on a rising straight line. Closes 1 through 20 give r of 1.

What does -1 mean?

They sit on a falling straight line. A countdown from 20 down to 1 also gives r of -1.

Why is the line empty?

Either the chart has fewer than 20 closes, or every close in the window is the same. A flat window is empty, not zero.

Is this correlation with another market?

No. It is correlation of the source with time, the position of the bar inside the window.

Does a shorter length help?

A shorter window reaches 1 and -1 more often, because fewer closes have to line up. The default is 20.

Does it repaint?

No. A closed bar's r stays. The live bar moves until it closes, because that close is inside the window.

Who defined r?

Karl Pearson, in a paper on correlation for the Royal Society, 1896. The indicator is that r, applied to a moving window of closes.

Related indicatorsMore statistical tools.

All statistical indicators

Try Correlation on a live chart.
Free. No download.

Works in your browser and on iPhone too.

Example market1h
r