This adds visual cue for when MACD histogram bars is decreasing when above the zero-line, and increasing when below the zero-line.
Based on:
Based on:
//@version=2 study("MACD Colors", overlay = false) // This adds visual cue for when MACD histogram bars is decreasing when above the zero-line, and // when increasing when below the zero-line. // // Based on: https://www.tradingview.com/script/4IYKX938-MACD-4C/ fastMA = input(title="Fast Length", type = integer, defval = 12) slowMA = input(title="Slow Length", type = integer, defval = 26) src = input(title="Source", type=source, defval=close) signalSmooth = input(title="Signal smoothing", type = integer, defval = 9) sma_macd = input(title="Simple MA (for MACD line)", type = bool, defval = false) sma_signal = input(title="Simple MA (for signal line)", type = bool, defval = false) MACDLine = if sma_macd sma(src, fastMA) - sma(src, slowMA) else ema(src, fastMA) - ema(src, slowMA) SignalLine = if sma_signal sma(MACDLine, signalSmooth) else ema(MACDLine, signalSmooth) MACDHistogram = MACDLine - SignalLine plotColor = if MACDHistogram > 0 MACDHistogram > MACDHistogram[1] ? lime : green else MACDHistogram < MACDHistogram[1] ? maroon : red plot(MACDLine, style = line, color = blue) plot(SignalLine, style = line, color = orange) plot(MACDHistogram, style = columns, color = plotColor) plot(0, title = "Zero line", linewidth = 1, color = gray)