What it measures

The linear regression indicator fits a straight line to the last n prices by least squares and plots where that line ends today. The slope of the line is the trend's speed; the standard deviation of price around the line gives a channel. It is a moving average that leans forward, with less lag and more overshoot.

The calculation

fit y = a + b·x through the last n closes, minimising the squared vertical distances linear regression value = a + b·(n − 1), the line's value at the current bar slope = b; channel = value ± k × standard deviation of the residuals

Pine's ta.linreg(source, length, offset) returns the line's value offset bars from the end, so offset 0 is the end point.

Inputs and defaults

  • Length: 14 to 100; the channel versions use longer windows.
  • Offset: 0.
  • Channel width: 2 standard deviations.

How it is read

A rising slope is an uptrend; the sign change of the slope is the signal most strategies code. Price at the channel's edge is read as stretched, with the same reversion-versus-breakout ambiguity as Bollinger Bands.

Where it fails

A straight line is the wrong model for a market that curves, and the fit is dominated by the ends of the window: the oldest bar leaving changes the slope as much as the newest arriving. The end point overshoots at turns. A regression channel drawn over a trend will contain the trend by construction and says nothing about whether it continues.

How the desk reads it

A regression-slope strategy is read as a trend rule with a lookback, and judged like one. A regression channel is read as Bollinger Bands on a tilted mean, with the same reversion-or-breakout ambiguity.

In the desk's screen

Of the 614 screened strategies in the library, 23 (3.7%) use this indicator somewhere in their logic.

11 of those were gross-profitable on enough cells to reach the after-fee replay.

The count is read from the compiled code of each strategy in the library; a strategy that computes the indicator by hand under another name is not counted. The desk's own rules are not part of the count.