MACD indicator: settings, histogram and crossovers in SuperCharting
How the MACD indicator works in SuperCharting: fast, slow and signal lengths, the coloured histogram, its two built-in alerts, and a MACD strategy test.
MACD (Moving average convergence divergence) is the gap between a fast and a slow exponential moving average, plotted with a signal line and a histogram. In SuperCharting you add it from Indicators by searching "macd". It opens in its own pane with TradingView's defaults of 12, 26 and 9. Below is what each part means, how to change it, and how to alert on crossovers.
The three parts of MACD
The built-in plots three things in its pane, plus a zero line:
- MACD: the 12-bar EMA of the close minus the 26-bar EMA. It is above zero when the short-term average is above the long-term one.
- Signal line (orange): a 9-bar EMA of the MACD line.
- Histogram: MACD minus the signal line, drawn as columns in four colours. Dark green means above zero and growing, light green above zero but shrinking. Light red means below zero and shrinking towards zero, bright red below zero and growing more negative.
The histogram colours show momentum changing before the lines cross. A run of shrinking dark-green columns turning light green tells you the gap between MACD and the signal line is closing.
MACD is not bounded like RSI. Its values are in price units, so a MACD of 40 on NSE:NIFTY and 0.0008 on EURUSD can mean the same thing. Compare MACD with its own history on the same symbol, not across symbols.
How to add and configure MACD in SuperCharting
- Open a chart, for example NSE:BANKNIFTY on the 15m interval.
- Click Indicators, type "macd" and click Moving average convergence divergence.
- Hover the legend line "MACD close 12 26 9" and click the gear for Settings.
- On Inputs, set Source (Close), Fast length (12), Slow length (26) and Signal length (9).
- Oscillator MA type and Signal MA type switch either average between EMA and SMA. TradingView's defaults are EMA for both.
- On Style, change any plot's colour, thickness or plot style. The Histogram can be shown as columns, a histogram or a line.
- Click Ok.
Some traders use faster settings for intraday charts, such as 8, 21 and 5. Others keep 12, 26 and 9 on every timeframe so readings are comparable. Whatever you choose, test it on your own symbol before relying on it.
Common ways to read MACD
- Signal-line crossover: MACD crossing above the signal line shows short-term momentum turning up. Crossing below shows it turning down. This is the same moment the histogram crosses zero.
- Zero-line crossover: MACD crossing zero means the 12-bar EMA has crossed the 26-bar EMA. It is a slower trend signal; see moving averages.
- Where the cross happens: a bullish signal-line cross well below zero is often treated differently from one above zero. Pullback traders in an uptrend watch for crosses back up near the zero line.
- Divergence: price making a higher high while the MACD peaks get lower suggests the move is losing strength. MACD has no divergence finder built in. Compare the peaks by eye, or use the RSI divergence tools described in the RSI guide.
MACD is built from moving averages, so it lags price. In sideways markets the lines cross back and forth often, and many of those crosses lead nowhere. This is a description of how the indicator behaves, not a recommendation to trade it.
Alerts on MACD
Open the MACD legend's More menu and choose Add alert on …. The condition list shows the two alerts the built-in defines:
- Rising to falling: the histogram goes from zero or above to below zero, so MACD has crossed below the signal line.
- Falling to rising: the histogram goes from zero or below to above zero, so MACD has crossed above the signal line.
An indicator alert runs the script with its default inputs (12, 26, 9 and EMA). Settings you changed in the dialog do not reach the alert. If you want crossovers on other settings, or only crosses on one side of zero, write a small script and change its default numbers. This one marks bullish crosses below zero and bearish crosses above zero, and gives each its own alert:
//@version=6
indicator("MACD cross alerts", "MACD x")
fastLen = input.int(12, "Fast length", minval = 1)
slowLen = input.int(26, "Slow length", minval = 1)
sigLen = input.int(9, "Signal length", minval = 1)
[macdLine, signalLine, hist] = ta.macd(close, fastLen, slowLen, sigLen)
plot(hist, "Histogram", hist >= 0 ? color.teal : color.red, style = plot.style_columns)
plot(macdLine, "MACD", color.blue)
plot(signalLine, "Signal", color.orange)
hline(0, "Zero")
bullCross = ta.crossover(macdLine, signalLine) and macdLine < 0
bearCross = ta.crossunder(macdLine, signalLine) and macdLine > 0
plotshape(bullCross, "Bull cross", shape.triangleup, location.bottom, color.teal)
plotshape(bearCross, "Bear cross", shape.triangledown, location.top, color.red)
alertcondition(bullCross, "MACD bull cross below zero", "MACD crossed above signal below zero")
alertcondition(bearCross, "MACD bear cross above zero", "MACD crossed below signal above zero")
Save it in the Script Editor and add it to the chart from My scripts in the Indicators dialog. Then choose Add alert on MACD x…. Set Trigger to Once per bar close so a cross is only reported once the bar has closed. The price alerts guide covers expiry and notifications.
Testing a MACD rule
The Strategies chip has a built-in MACD strategy. It enters long when the MACD-minus-signal value crosses above zero and short when it crosses below, with Fast length 12, Slow length 26 and MACD length 9. Add it to a chart such as XAUUSD on 1h, then open the Strategy Tester from the legend's More menu to see net profit, drawdown and the list of trades. Set Commission and Slippage on the Properties tab, because a crossover system trades often and costs add up. Past results do not guarantee future results.
The Indicators chip also has Percentage volume oscillator and Price oscillator. They express the same fast-versus-slow average gap in other units, for example as a percentage.
Frequently asked questions
Why does my MACD look different from another site's?
Check the source, the three lengths and both MA types. If the history differs, for example a feed with fewer bars or different session times, the EMAs start from different values and can differ slightly for a while.
Can I put MACD on the price pane?
Use Move to in the legend's More menu to choose an existing pane or a new one. MACD values are far from price, so it is clearer in its own pane.
Can I use MACD on RSI or another indicator?
Yes. Open MACD's settings and choose another indicator's plot as Source; see indicators on indicators.
Does MACD repaint?
The built-in uses only closed and current bar values. The current bar's values change until the bar closes, then they stay fixed.