ta.linreg
Linear regression line value: least squares fit over length bars, evaluated at offset bars back from the newest.
ta.linreg(source: float, length: simple int, offset: int = 0) -> series float
Parameters
sourcefloat: The values to use, usually close or another price; a series that may change on every bar.lengthsimple int: Number of bars, a whole number from 1 to 5000 (a fraction is cut off). Known before the first bar: a literal or an input, never a series. Outside 1 to 5000 the script stops with a runtime error.offsetint: Bars back from the newest bar at which the fitted line is read (default 0, the newest bar); a negative offset reads the line past the newest bar.
Example
ta.linreg(close, 50, 0)