indicator · on price · open source
Variable Index Dynamic Average
Running…
Loading chart…
About
Variable Index Dynamic Average (VIDYA) adapts its smoothing constant to a CMO-style volatility index. Faster than an EMA in trends, calmer in chop — a popular alternative to KAMA.
- Use as a single-line trend filter that auto-adjusts.
- Raise N to slow its adaptation; lower it to react faster.
- Pair with a band or ATR stop for adaptive trend entries.
Source code
//@version=5
indicator("Variable Index Dynamic Average", overlay=true)
len = input.int(14, "Length", minval=2, maxval=200)
src = input.source("close", "Source")
cmo = math.abs(ta.change(src)) / ta.stdev(src, len)
vi = math.abs(cmo)
var float vidya = 0.0
vidya := nz(vidya[1], src) + (2.0 * vi / (len + 2.0)) * (src - nz(vidya[1], src))
p_VIDYA = plot(vidya, "VIDYA", color=color.orange, linewidth=2)
alertcondition(ta.crossover(close, vidya), "Price crosses above VIDYA", "Price crossed above VIDYA")
alertcondition(ta.crossunder(close, vidya), "Price crosses below VIDYA", "Price crossed below VIDYA")
No comments yet.
Sign in to comment.