Levels

Linear Regression Channel on a Live Gold Chart

The Linear Regression Channel fits one straight line through the last 100 closes, then draws a channel above and below it, two deviations wide. The line is the best-fit trend of that window, and the channel shows how far closes have strayed from it. On the hourly gold chart below, that window is roughly the last four trading days.

Loading the live chart.

Close
–

Open the gold chart

What it shows

Three lines that cover only the last Length candles, not the whole chart: the regression line in the middle, an upper channel line and a lower channel line. With the correlation value switched on, a number for the latest candle tells you how straight the window has been.

How Pravex works it out

  1. Take the last Length candles, or all candles if the chart holds fewer. Number them from 0 for the oldest, and fit a least squares line through their source values: the straight line with the smallest total squared distance to them.
  2. Deviation: measure how far each source value sits above or below that line, square each distance, add them up, divide by Length − 1 and take the square root. Only the window you fitted is used.
  3. Upper channel = line + upper multiplier × deviation. Lower channel = line − lower multiplier × deviation. Each side can be switched off, and each has its own multiplier (2 by default).
  4. The correlation value (Pearson’s R) is the correlation between candle number and the source over the same window. It reads +1 for a perfectly straight rise, −1 for a perfectly straight fall and 0 when there is no straight-line link, and it is 0 if the window has no variation at all.

Settings

SettingDefaultWhat changing it does
Length100How many of the latest candles the line is fitted through. A shorter Length follows recent price closely; a longer one draws a flatter, steadier trend.
SourcecloseThe price the line is fitted through and the deviation measured from.
Upper line (deviations)On, 2Switches the upper channel line on or off. The number next to it is how many deviations above the line it sits.
Lower line (deviations)On, 2Switches the lower channel line on or off. The number next to it is how many deviations below the line it sits.
Show the correlation valueOnShows the correlation value for the latest candle. Turn it off to hide the number.
Carry the lines leftOffDraws the lines further back, to the left of the fitted window.
Carry the lines rightOnCarries the lines on to the right of the latest candle, so you can see where the fitted path leads if price kept to it.

How traders read it

The middle line is the trend of the window, and its slope says whether the last Length candles went up or down on average. Closes hugging the line suggest an orderly move; closes spread wide say a noisy one. Pearson’s R puts a number on that: near +1 or −1 is a clean trend, near 0 means the line is not describing much.

Traders read the outer lines as stretch levels. Price at the upper line is as far above the fitted trend as 2 deviations of this window allow. Some look for a bounce back toward the middle; others read a close outside the channel as a break from the trend.

The fit uses only the last Length candles, so every new candle can change the whole picture.

When it misleads

The line is redrawn from scratch on every new candle, since the window slides. A channel that looked perfect last hour is gone this hour, and the old touches no longer count. The deviation is measured about the fitted line within the same window, so it describes the past Length candles and nothing outside them. A straight line is also a poor model for a market that turns; after a reversal it keeps describing the old trend for a long while. Pearson’s R only tells you how straight the window was, not whether it will continue.

Questions and answers

What does it mean when gold closes outside the regression channel?

The close sits more than 2 deviations of this window away from the fitted line. On a window that has been a tidy trend, that is a big stray. It can be the start of a new leg, or a spike that drifts back toward the middle; the channel alone cannot tell which.

What does Pearson’s R mean?

It measures how close the last Length closes are to a straight line, from −1 (a straight fall) through 0 (no line) to +1 (a straight rise).

How many candles should a regression channel on gold cover?

Pravex fits 100 closes by default. Match the window to the swing you want to describe: about one trading week of hourly candles for the current leg, a few hundred for the larger trend. A short window redraws its slope often; a long one keeps describing an old trend after price turns.

Why does the regression channel redraw after each new candle?

It is refitted each time. When a candle arrives, the oldest one drops out of the window and the straight line is fitted again through the new set, so the slope, the channel width and every past point of the drawing can shift. A touch of the upper line you saw yesterday may not be a touch on today’s fit. This is a real redraw of past values, unlike an average whose old points stay fixed.

Related: Bollinger Bands, Least Squares Moving Average, Keltner Channels, Donchian Channels, every indicator.

Not financial advice. Read our disclaimer.

Pro charts. Zero paywalls.

Charts for gold, oil, US indices and crypto, with every tool free to use.

Open the chart

No card, no trial, no upgrade pop-ups.