indicator · own pane · open source
Adaptive RSI
Running…
Loading chart…
About
Adaptive RSI — Kaufman's Efficiency Ratio drives the RSI length. In choppy markets the RSI looks at 100 bars (almost noise); in trends it tightens to ~20 bars so it actually turns with price.
- Same 30/70 extremes, but they fire more reliably than fixed-length RSI.
Source code
//@version=5
indicator("Adaptive RSI", overlay=false)
len = input.int(14, "Base length", minval=5, maxval=100)
cumAbs = ta.cum(math.abs(ta.change(close)))
sumAbs = cumAbs - cumAbs[len]
er = math.abs(close - close[len]) / math.max(sumAbs, 0.0001)
alpha = math.max(0.01, er)
adaptLen = na(er) ? 50 : math.max(20, math.min(100, math.round(1 / alpha)))
adaptRsi = ta.rsi(close, math.max(2, adaptLen))
hline(70, "OB", color=color.gray)
hline(30, "OS", color=color.gray)
p_Adaptive_RSI = plot(adaptRsi, "Adaptive RSI", color=color.purple, linewidth=2)
alertcondition(ta.crossover(adaptRsi, 70), "Adaptive OB", "Adaptive RSI above 70")
alertcondition(ta.crossunder(adaptRsi, 30), "Adaptive OS", "Adaptive RSI below 30")
No comments yet.
Sign in to comment.