talib.linreg

Fits a linear regression to source across length bars and returns a value from that fit. The offset argument shifts which point of the fit you get back.

talib.linreg(series float source, series int length, series int offset) → series float
ParameterTypeRequiredDescription
sourceseries floatyesThe series the line is fitted to.
lengthseries intyesHow many bars the fit covers.
offsetseries intyesShifts the point on the fit that is returned. An int.

Returns series float — A series float taken from the fitted line.

indicator("Linear regression")
plot(talib.linreg(close, 20, 0))

See also talib.alma · talib.atr · talib.barssince

Part of the function index.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade