SV

Street Verdict

Analyst Scorecard

All indicators
Trend

MACD (Moving Average Convergence Divergence)

Is momentum building or fading?

The gap between a fast and a slow EMA, and a smoothed copy of that gap, to show when momentum changes.

MACD on a chart of past prices

Stock
Period
Loading RELIANCE daily prices…

Settings: move a slider and the chart redraws

12

The quicker of the two averages.

26

The slower average subtracted from the fast one.

9

How much the MACD line is smoothed into the signal line.

What it measures

MACD subtracts a slow EMA (26 days) from a fast one (12 days). That difference is the MACD line: above zero, the recent average is higher than the longer one, so prices have been rising; below zero, falling.

The signal line is a 9-day EMA of the MACD line itself, a slower copy of it. The bars (the histogram) are the gap between the two: MACD minus signal, the same on this page, in the chart workbench and in scripts.

Because it is built from averages, MACD follows the trend, and the bars show its speed: when they shrink, the move is slowing down even if the price is still rising.

How traders read it

  • MACD line crossing above the signal line: momentum is turning up. Crossing below: turning down. These are the classic MACD signals, marked on the chart.
  • MACD above zero: the fast average is above the slow one, the same thing a moving-average crossover looks at.
  • Growing bars: the move is speeding up. Shrinking bars: slowing down.
  • Divergence: the price makes a new high but MACD makes a lower high. Traders read that as a tiring move; often nothing follows.

The traps

Late twice over

MACD's signal line is an average of a difference of averages, so its crossings come later than the price turns.

Whipsaws near zero

In a sideways market the two lines hug each other and cross often, and each cross is a trade with costs.

No fixed scale

MACD is in ₹, so 20 is a lot for a ₹200 stock and little for a ₹5,000 one. You cannot call a MACD value 'high' or compare it across stocks the way you can with RSI.

Test the classic rule: MACD crossover

Would following the textbook signal have made money on this stock, after every cost, compared with just holding it? Run it and see.

Waiting for prices…

Quick check

Three questions on RELIANCE's own chart, with the classic settings. Get two right to mark MACD as done.

Waiting for prices…

Use it in a script

function run(bars, ta, helpers) {
  const m = ta.macd(helpers.closes(bars), 12, 26, 9);   // .dif = MACD line, .dea = signal line
  const signals = [];
  for (let i = 0; i < bars.length; i++) {
    if (m[i].dif > m[i].dea) signals.push(helpers.buy(i));        // MACD above its signal line
    else if (m[i].dif < m[i].dea) signals.push(helpers.sell(i));  // MACD below its signal line
  }
  return helpers.finalize(signals);   // keeps the first of each run: the crossovers
}

This is the rule tested above, with the settings on your sliders, and it gives exactly the same buy and sell candles. Paste it into the Scripts drawer of the chart workbench, or save it and compare it across stocks in the Strategy Lab. New to scripts? The Writing strategies track starts from zero.

In the reference:ta.macdhelpers.finalize