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
| Parameter | Type | Default | Bounds or options | Description |
|---|---|---|---|---|
| Time Period | integer | 14 | 2…100000 | Number of closing-price observations used for each least-squares slope calculation. |
Outputs
| Output | Type | Description |
|---|---|---|
| Linear Regression Slope | number | Rolling 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
- Treating slope as a return without normalizing by price and elapsed time.
- Reading a positive value as a guaranteed positive next return.
- Ignoring outlier sensitivity inside a short window.
- 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.