Skip to main content
Studies · Statistical

Linear Regression

linearRegression · Rolling OLS fit against the bar index, with slope, angle and R²

Drawn in its own panelReads one column (close here)
Hover the chart to read values · practice data: a seeded random walk with no overnight gaps

What it measures

Fits a straight line through the last N closes (least squares) and reports five facts about that line: where it ends today, how steep it is, where it started, its angle, and how well a straight line explains the prices (R²).

How traders use it

  • Value is a low-lag moving average: the end point of the fitted line follows price more closely than an SMA of the same length.
  • Slope says which way and how fast the recent trend is moving; a slope crossing zero is a trend change.
  • R² near 1 means prices have moved in a clean straight line (a strong, orderly trend); near 0 means no linear trend.
  • Mean reversion traders measure how far price has strayed from the regression line.

Parameters

NameValueDefaultAllowedWhat it does
period14≥ 2
usual 5–60
Number of bars in each fit.

Outputs

ValueThe fitted line’s value at today’s bar.
SlopeChange in the fitted line per bar, in price units.
InterceptThe fitted line’s value at the oldest bar of the window.
AngleThe slope as an angle in degrees. It depends on the price scale, so compare it only with itself.
R2R²: the share of the price variation the line explains, 0 to 1.

Drawn in one colour, one line per output, told apart by line texture. Hover the chart to read each one.

Good to know

All five outputs share one axis here, so Value and Intercept (price-sized numbers) squash Slope, Angle and R² flat near zero. Hover the chart to read them. Tidal draws every multi-output study on one shared axis today.