indicator · on price · open source
Linear Regression Moving Average
Running…
Loading chart…
About
Linear Regression Moving Average fits a least-squares line through the last N bars and plots its current value. Smoother than an EMA with comparable length and slightly leading in trends.
- Less lag than SMAs/EMAs, ideal for trend-confirmation crossovers.
- Raise N for smoother trend lines; lower it for faster turns.
- Best on trending assets; produces odd signals in tight ranges.
Source code
//@version=5
indicator("Linear Regression Moving Average", overlay=true)
len = input.int(14, "Length", minval=2, maxval=500)
src = input.source("close", "Source")
lrma = ta.linreg(src, len, 0)
p_LinReg_MA = plot(lrma, "LinReg MA", color=color.silver, linewidth=2)
alertcondition(ta.crossover(close, lrma), "Price crosses above LinReg", "Price crossed above the linear-regression line")
alertcondition(ta.crossunder(close, lrma), "Price crosses below LinReg", "Price crossed below the linear-regression line")
No comments yet.
Sign in to comment.