Rafmed

Variable Index Dynamic Average

//@version=3
// Copyright (c) 2018-present, Alex Orekhov (everget)
// Variable Index Dynamic Average script may be freely distributed under the MIT license.
study(title="Variable Index Dynamic Average", shorttitle="VIDYA", overlay=true)

length = input(title="Length", type=integer, defval=14)
highlightMovements = input(title="Highlight Movements ?", type=bool, defval=true)
src = input(title="Source", type=source, defval=close)

// Chande Momentum Oscillator
getCMO(src, length) =>
mom = change(src)
upSum = sum(max(mom, 0), length)
downSum = sum(-min(mom, 0), length)
out = (upSum - downSum) / (upSum + downSum)
out

cmo = abs(getCMO(src, length))

alpha = 2 / (length + 1)

vidya = 0.0
vidya := src * alpha * cmo + nz(vidya) * (1 - alpha * cmo)

vidyaColor = highlightMovements ? (vidya > vidya ? green : red) : #6d1e7f
plot(vidya, title="VIDYA", linewidth=2, color=vidyaColor, transp=0)
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?