Why the volume version of ATR of vawma function cannot work in Pine Script?

17 Views Asked by At

The original VWMA and WMA combined = VAWMA(// © Electrified (electrifiedtrading)(https://tw.tradingview.com/script/MDNfJENm-Moving-Average-Weighted-Volume-Adjusted/)). Why my volume version of ATR can not work?

    vawmaatr(src, len)=>
    sum = 0.0
    vol = 0.0
    for m = 1 to len by 1
        i = len - m
        v = volume[i] * m
        vol += v
        tr = math.max(high[i] - low[i], math.abs(high[i] - close[i - 1]), math.abs(low[i] - close[i - 1]))
        sum += tr * v
    vwatr = sum / vol
    ta.stdev(vwatr, len)
vawmaatrvalue = vawmaatr(close, 14)
plot(vawmaatrvalue, linewidth=4)
0

There are 0 best solutions below