indicator · own pane · open source

Adaptive Stochastic

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

About

Adaptive Stochastic — the %K lookback widens in chop (fewer signals) and tightens in trend (more signals), driven by the Efficiency Ratio.

  • Same 20/80 extremes, just better-timed.

Source code

//@version=5
indicator("Adaptive Stochastic", 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))))
kRaw = ta.stoch(close, high, low, aLen)
hline(80, "OB", color=color.gray)
hline(20, "OS", color=color.gray)
p_K = plot(kRaw, "K", color=color.blue)
alertcondition(ta.crossover(kRaw, 20), "Stoch above OS", "Adaptive stochastic crossed up from oversold")
alertcondition(ta.crossunder(kRaw, 80), "Stoch below OB", "Adaptive stochastic crossed down from overbought")

Comments

No comments yet.

Sign in to comment.