indicator · own pane · open source
Linear Regression Slope
Running…
Loading chart…
About
Linear Regression Slope is the per-bar change of the regression line — it shows how fast the trend is moving, not just its level.
- Above zero = trend accelerating upward, below zero = accelerating downward.
- Flat near zero = trend exhaustion or reversal.
- Divergences between slope and price often precede reversals.
Source code
//@version=5
indicator("Linear Regression Slope", overlay=false)
len = input.int(14, "Length", minval=2)
lrVal = ta.linreg(close, len, 0)
slope = lrVal - lrVal[1]
hline(0, "Zero", color=color.gray, linestyle=hline.style_dashed)
p_Slope = plot(slope, "Slope", color=slope >= 0 ? color.green : color.red, linewidth=2)
alertcondition(ta.crossover(slope, 0), "Slope turns up", "Linear regression slope crossed above zero")
alertcondition(ta.crossunder(slope, 0), "Slope turns down", "Linear regression slope crossed below zero")
No comments yet.
Sign in to comment.