Functions
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.
Syntax
talib.linreg(series float source, series int length, series int offset) → series float
Arguments
source required series float The series the line is fitted to. length required series int How many bars the fit covers. offset required series int Shifts the point on the fit that is returned. An int. Return Type
series float Example
indicator("Linear Regression Line", overlay=true)
length = input(20, "Length")
source = input(close, "Source")
offset = input(0, "Offset")
linreg = talib.linreg(source, length, offset)
plot(linreg, color=color.blue, title="Linear Regression")