indicator · own pane · open source

Adaptive ATR

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

About

Adaptive ATR — the ATR lookback adapts via the Efficiency Ratio. ATR tightens when price is moving and widens in chop, giving a volatility measure that matches the actual swing size.

  • Use as a dynamic stop multiplier (e.g. 2 × adaptive ATR).

Source code

//@version=5
indicator("Adaptive ATR", 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)
aLen = na(er) ? 14 : math.max(5, math.min(200, math.round(len * (1 - er / 2))))
adAtr = ta.atr(aLen)
p_Adaptive_ATR = plot(adAtr, "Adaptive ATR", color=color.orange, linewidth=2)
alertcondition(ta.crossover(adAtr, ta.sma(adAtr, 50)), "Vol expanding", "Adaptive ATR above its 50-bar mean")
alertcondition(ta.crossunder(adAtr, ta.sma(adAtr, 50)), "Vol contracting", "Adaptive ATR below its 50-bar mean")

Comments

No comments yet.

Sign in to comment.