← Back to Library
Momentum

MACD

The Moving Average Convergence Divergence (MACD) is a trend-following momentum indicator that shows the relationship between two moving averages of a security's price. This V6 implementation includes color-coded histograms for better visualization.

Pine Script V6
//@version=6
indicator('MACD', overlay=false)
[m,s,h] = ta.macd(close, 12, 26, 9)
plot(h,'Hist',style=plot.style_columns,color=(h>=0?(h<h[1]?#26A69A:#B2DFDB):(h>h[1]?#FFCDD2:#FF5252)))
plot(m,'MACD',color=color.blue)
plot(s,'Signal',color=color.orange)