indicator · on price · open source

Linear Regression

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

Linear Regression curve fits a straight line to the last N closes — the cleanest trend line you can draw programmatically.

  • Price above the line = bullish bias, below = bearish bias.
  • Touches of the line often act as dynamic support/resistance.
  • Combine two regressions of different windows for a ribbon.

Source code

//@version=5
indicator("Linear Regression", overlay=true)
len = input.int(14, "Length", minval=2)
lrVal = ta.linreg(close, len, 0)
p_Linear_Reg = plot(lrVal, "Linear Reg", color=color.blue, linewidth=2)
alertcondition(ta.crossover(close, lrVal), "Price above regression", "Close crossed above the regression line")
alertcondition(ta.crossunder(close, lrVal), "Price below regression", "Close crossed below the regression line")

Comments

No comments yet.

Sign in to comment.