Trend · 500-2,000/mo

MACD Buy Sell Signals: Complete TradingView Guide

MACD buy sell signals for TradingView. Crossover, histogram, and divergence signals with Pine Script code and real SPY, BTC examples.

MACD Signal Interpretation

Quick-reference guide to 7 signal types you will see on the chart.

Signal TypeIndicator ConditionMarket MeaningReliability
MACD Line Crossover (Bullish)MACD line crosses above the signal line (histogram turns positive)Short-term momentum has shifted upward. Trend reversal or continuation expected. Most reliable when above the zero line in an uptrend.4/5
MACD Line Crossunder (Bearish)MACD line crosses below the signal line (histogram turns negative)Short-term momentum has shifted downward. Trend reversal or pullback expected. Most reliable when below the zero line in a downtrend.4/5
Zero Line Crossover (Bullish)MACD line crosses above the zero lineMomentum has turned positive. Confirms a new uptrend after a bearish period. Works well on weekly charts for macro direction.3/5
Zero Line Crossunder (Bearish)MACD line crosses below the zero lineMomentum has turned negative. Confirms a new downtrend after a bullish period. Lagging signal but filters out false range moves.3/5
Hidden Bullish DivergencePrice makes higher low while MACD histogram makes lower lowPullback in an uptrend is losing momentum. The trend is likely to resume upward. High reliability signal on daily and 4H charts.5/5
Hidden Bearish DivergencePrice makes lower high while MACD histogram makes higher highThe bounce in a downtrend is weak. Selling pressure is building. Trend resumption downward is the higher probability outcome.5/5
Histogram Slope ReversalHistogram bars stop expanding and start contracting near zeroThe current momentum wave is exhausting. A directional change in the MACD line is coming. Use as an early warning, not a standalone entry.2/5

MACD Pine Script Signal Code

Ready-to-use Pine Script code for generating buy/sell signals. Copy and paste into your TradingView Pine Editor.

Pine Script v5
//@version=5
indicator("MACD Buy Sell Signals", overlay=false)

fastLength = input.int(12, "Fast Length")
slowLength = input.int(26, "Slow Length")
signalSmoothing = input.int(9, "Signal Smoothing")
src = input.source(close, "Source")

[macdLine, signalLine, histLine] = ta.macd(src, fastLength, slowLength, signalSmoothing)

// Crossover signals
bullishCross = ta.crossover(macdLine, signalLine)
bearishCross = ta.crossunder(macdLine, signalLine)

// Zero line cross signals
bullishZero = ta.crossover(macdLine, 0)
bearishZero = ta.crossunder(macdLine, 0)

// Divergence detection (simplified)
higherLowPrice = low > low[1] and macdLine < macdLine[1]
bullDiv = low[2] > low and macdLine[2] < macdLine
lowerHighPrice = high < high[1] and macdLine > macdLine[1]
bearDiv = high[2] < high and macdLine[2] > macdLine

plot(macdLine, "MACD Line", color=#2962FF, linewidth=2)
plot(signalLine, "Signal Line", color=#FF6D00, linewidth=1)
hline(0, "Zero Line", color=#757575, linestyle=hline.style_dashed)

plot(histLine, "Histogram", color=histLine >= 0 ? color.new(#26A69A, 30) : color.new(#EF5350, 30), style=plot.style_histogram, linewidth=1)

plotshape(bullishCross, "Bullish Cross", shape.triangleup, location.bottom, color=#4CAF50, size=size.small)
plotshape(bearishCross, "Bearish Cross", shape.triangledown, location.top, color=#FF5252, size=size.small)
plotshape(bullishZero, "Bullish Zero Cross", shape.labelup, location.bottom, color=#26A69A, size=size.small)
plotshape(bearishZero, "Bearish Zero Cross", shape.labeldown, location.top, color=#EF5350, size=size.small)
plotshape(bullDiv, "Bull Div", shape.labelup, location.bottom, color=#00BCD4, size=size.small)
plotshape(bearDiv, "Bear Div", shape.labeldown, location.top, color=#FF9800, size=size.small)

alertcondition(bullishCross, "MACD Bullish Cross", "MACD line crossed above signal line")
alertcondition(bearishCross, "MACD Bearish Cross", "MACD line crossed below signal line")
alertcondition(bullishZero, "MACD Bullish Zero Cross", "MACD line crossed above zero")
alertcondition(bearishZero, "MACD Bearish Zero Cross", "MACD line crossed below zero")
alertcondition(bullDiv, "MACD Bullish Divergence", "Hidden bullish divergence detected on MACD")
alertcondition(bearDiv, "MACD Bearish Divergence", "Hidden bearish divergence detected on MACD")

Recommended Parameters for MACD

Parameter settings tested across different market conditions and timeframes.

Feature comparison table: Default vs Description
ParameterDefaultDescription
Fast Length12Number of bars for the fast EMA. Tighter values (8-10) make the MACD more responsive. Wider values (14-16) reduce whipsaws on choppy daily charts.
Slow Length26Number of bars for the slow EMA. The 12/26 pair is standard from Gerald Appels original design. I tested 8/21 on ES 15m charts which gave earlier entries but added false signals in ranging sessions.
Signal Smoothing9The EMA period applied to the MACD line to produce the signal line. Lower values (5-7) trigger faster crossovers but generate more noise. Higher values (12-14) produce fewer, higher-quality signals.
SourceClosePrice input for the MACD calculation. Close is standard. HLC3 provides a more neutral reading on volatile names like BTC where wicks distort single price sources.

MACD + Pineify Invite-Only: Better Together

MACD alone gives you one signal type. Pineify invite-only indicator combines MACD with RSI divergences, MACD confirmation, and Supertrend filters in one overlay. Fewer charts, clearer signals.

Instead of switching between 7 different signals on separate charts, you get a single multi-confirmation setup.

See the Invite-Only Indicator

FAQ

MACD Signals FAQ

Stop juggling MACD with 4 other charts

Pineify combines MACD, RSI, MACD, and Supertrend into one invite-only indicator. One click setup.

Try Pineify Free