I have also added an option to draw eVWMA (eVWMA on HLC).
List of all my indicators:
- Chart: - GDoc: https://docs.google.com/document/d/15AGC...
// // @author LazyBear // List of all my indicators: https://www.tradingview.com/v/4IneGo8h/ // study("Elastic Volume Weighted Moving Average [LazyBear]", shorttitle="EVWMA_LB", overlay=true) length=input(20) useCV=input(false, type=bool, title="Use Cumulative Volume") renderBands=input(false, type=bool, title="Draw Envelope") nbfs = useCV ? cum(volume) : sum(volume, length) medianSrc=close calc_evwma(price, length, nb_floating_shares) => data = (nz(data) * (nb_floating_shares - volume)/nb_floating_shares) + (volume*price/nb_floating_shares) data m=calc_evwma(medianSrc, length, nbfs) plot(m, color=maroon, linewidth=2, title="evwma") plot(renderBands ? calc_evwma(high, length, nbfs): na, color=red , linewidth=2, title="evwma+") plot(renderBands ? calc_evwma(low, length, nbfs) : na, color=green, linewidth=2, title="evwma-")
Thanks LazyBear for the addition!!!
This formula here shows the step-by-step calculation of the VWMA as an incremental/rolling calculation: http://people.ds.cam.ac.uk/fanf2/hermes/doc/antiforgery/stats.pdf, Eq 4-53
U = Un-1 + w / Wn * (x - Un-1)
let Wn = nb_floating_shares (sum of volume (weight) N bars back)
let w = current volume (current weight)
let x = price
let Un-1 = previous MA calculation
let Un = current MA
from line 12 of this script in the calc_evwma function, substituting the above variables:
U = Un-1 * (Wn - w) / Wn + (w * x / Wn)
= Un-1 / Wn * (Wn - w) + w * x / Wn
= Un-1 - Un-1 * w / Wn + w * x / Wn
= Un-1 + w / Wn * (x - Un-1)
This is the exact same formula in the final value in Equation 4-53 above. This is also the same calculation here https://www.tradingsetupsreview.com/volume-weighted-moving-average-vwma/
The Trading View calculation of vwma is wrong, it should be the above. The elastic volume weighted moving average is simply another form of the normal VWMA formula, it is not a new moving average.
Sorry to be extra-dense, but would it be possible for you to script-up the correct implementation of the eVWMA (or whatever it is you've commented above)?
And thank you for sharing those articles. I love when people leave gold in the comments.
According to the definition of eVWMA presented in the paper, “Wn” here should be a constant, i.e. total number of shares, that doesn’t have to do with sum of Wi (which would be the total volumes of interest). With Wn != sum of Wi, the equations above do not check out. Hence, it’s more like a volume weighted “cumulative” average (or a special case of VWMA, where all historical volumes are considered), plus a decaying effect on previous trades. Does it make sense?