Statistic functions

Linear Regression Slope

Slope per bar of a rolling least-squares regression line.

Engine
TA-Lib
Function
LINEARREG_SLOPE
Input series
close
Outputs
1

How it works

LINEARREG_SLOPE fits a least-squares line to each close window using sequential bar positions and returns its slope coefficient, expressed as source-value change per bar.

Use case

Use Linear Regression Slope as a signed trend-direction and trend-steepness feature over a fixed rolling window.

Parameters

ParameterTypeDefaultBounds or optionsDescription
Time Periodinteger142…100000Number of closing-price observations used for each least-squares slope calculation.

Outputs

OutputTypeDescription
Linear Regression SlopenumberRolling least-squares regression slope in source-value units per bar.

Reading the result

Linear Regression Slope describes the signed rise or fall of the rolling least-squares line per bar. Positive values indicate an upward fitted direction and negative values a downward fitted direction.

The magnitude remains dependent on source-price units and bar duration. A slope from one-minute bars is not directly comparable with the same numeric slope from daily bars or a differently priced asset.

Common mistakes

  1. Treating slope as a return without normalizing by price and elapsed time.
  2. Reading a positive value as a guaranteed positive next return.
  3. Ignoring outlier sensitivity inside a short window.
  4. Comparing slopes across symbols without a defined scale transformation.

DataCat workflow notes

For cross-asset features, normalize slope explicitly and record the transformation. Pair it with the fitted endpoint or a dispersion measure when the quality and scale of the local linear approximation matter.

Resources

Search documentation

Search across 46 documentation pages.