Advanced MACD
Advanced MACD
Advanced MACD
if isSMACD
fastStoch = (fastMA - lowest(low, stochLength)) /
(highest(high, stochLength) - lowest(low, stochLength))
slowStoch = (slowMA - lowest(low, stochLength)) /
(highest(high, stochLength) - lowest(low, stochLength))
macd := (fastStoch - slowStoch) * 100
macd := ma(stochType, macd, signalLength)
signal = ma(signalType, macd, signalLength)
hist = macd - signal
plot(macd, title='MACD', color=#000099, linewidth=1)
plot(signal, title='Signal', color=#990000, linewidth=1)
plot(hist, title='Histogram', color=#009900, linewidth=3, transp=70,
style=plot.style_histogram)
hline(0, title="Zero", color=color.gray, linestyle=hline.style_dashed)
The indicator also allows you to volume weight the indicator (turned on by
default), which will turn it into a Volume-Weighted Moving Average Convergence
Divergence (VW-MACD) first used by Buff Pelz Dormeier in 2002 and described in
detail in his book "Investing with Volume Analysis: Identify, Follow, and Profit
from Trends". If you want to weight the oscillator against the true range instead
of volume this is also possible. By default, this will be done automatically for
assets that do not support volume .