HPotter

The Volume-Weighted MACD Histogram

The related article is copyrighted material from Stocks & Commodities 2009 Oct

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?
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 29/08/2014
// The related article is copyrighted material from Stocks & Commodities 2009 Oct 
////////////////////////////////////////////////////////////
study(title="Combining Exponential And Volume Weighting")
Long_period = input(26, minval=1)
Short_period = input(12, minval=1)
Smoothing_period = input(9, minval=1)
xLongMAVolPrice = ema(volume * close, Long_period) 
xLongMAVol = ema(volume, Long_period) 
xResLong = (xLongMAVolPrice * Long_period) / (xLongMAVol * Long_period)
xShortMAVolPrice = ema(volume * close, Short_period) 
xShortMAVol = ema(volume, Short_period) 
xResShort = (xShortMAVolPrice * Short_period) / (xShortMAVol * Short_period)
xVMACD = xResShort - xResLong
xVMACDSignal = ema(xVMACD, Smoothing_period)
nRes = xVMACD - xVMACDSignal
plot(nRes, color=blue, style = histogram )