About

MACD compares a fast average of the price with a slow one. It shows how far apart they are. It also shows if that gap grows or shrinks.

In KAGAMI it is called CBc MACD 12-26-9 in the Indicators list. It is KAGAMI's own: KAGAMI's servers compute it, and the chart draws the result. It is free for every account.

The list also has the chart's own MACD. That is a different version; see the differences.

What you see on the chart

A chart is made of bars, also called candles. Each bar covers the same amount of time, for example 15 minutes.

  • CBc MACD opens in its own pane: a separate strip under the price chart.
  • The thick indigo line is the MACD line.
  • The thin gold line is the Signal line. It is a slower copy of the MACD line.
  • The columns are the Histogram. They show the gap between the two lines.
  • A column is green when the MACD line is at or above the Signal line. It is red when the MACD line is below it.
  • Its name, CBc MACD, and its three settings show at the pane's top left.

How traders often read it

  • Above zero, the MACD line means the fast average is above the slow one. Recent prices were higher than older ones, on average.
  • Below zero means the opposite.
  • Many traders watch when the MACD line crosses the Signal line. The columns switch colour at that moment.
  • Some traders watch the columns grow or shrink. Shrinking columns mean the two lines are coming together.
  • Some traders compare highs. The price makes a new high, but MACD makes a lower one. This is called a divergence.
A daily chart of AAPL with CBc MACD in its own pane below. The indigo MACD line and the gold Signal line rise from below zero, stay above zero for weeks, then fall. The columns under them are red, then green, then red again.A daily chart of AAPL with CBc MACD in its own pane below. The indigo MACD line and the gold Signal line rise from below zero, stay above zero for weeks, then fall. The columns under them are red, then green, then red again.
AAPL, daily candles, with CBc MACD 12-26-9 in its pane below. 1 — the MACD line crosses above the Signal line, and the columns turn green. 2 — the MACD line crosses above zero: the fast average is now above the slow one. 3 — the columns shrink, then the MACD line crosses below the Signal line, and the columns turn red.

An indicator only describes past prices. It cannot tell you what happens next.

The settings

Point at CBc MACD at the top left of its pane. Click the gear icon (Settings). The Inputs tab shows:

  • Fast — how many bars the fast average uses. It starts at 12.
  • Slow — how many bars the slow average uses. It starts at 26.
  • Signal — how many bars the Signal line averages. It starts at 9.

Each one takes a whole number from 1 to 500. When you change one, the chart asks KAGAMI's servers again. The lines are redrawn a moment later.

The Style tab holds the colours and line widths.

CBc MACD always uses the closing price of each bar. It always uses one kind of average, the EMA (explained below). There are no settings to change those.

When it can mislead

  • It is late by design. It is built from averages, so it moves after the price moves.
  • Sideways markets. When the price goes nowhere, the lines cross often. Those crossings say little.
  • The last bar is still forming. The newest values move until that bar closes.
  • Values are in price units. A MACD of 2 means more for a 20-dollar stock than for a 500-dollar one. Do not compare MACD values between markets.
  • Big settings need many bars. With very large numbers, the lines start late. The Signal line and columns can even stay empty.
  • Fast bigger than Slow turns the picture upside down. Keep Fast below Slow to read it the usual way.

Charts are for learning, not advice. Read our Risk Disclaimer.

An example

Open NASDAQ:AAPL on a 15-minute chart. These numbers are made up.

  1. Say the 12-bar fast average is 101. The 26-bar slow average is 100.
  2. The MACD line is 101 − 100 = 1.
  3. Say the Signal line is 0.8.
  4. The column is 1 − 0.8 = 0.2. It is small and green.
  5. Over the next bars, say the MACD line falls to 0.7. The Signal line falls to 0.78.
  6. The column is now 0.7 − 0.78 = −0.08. It turns red. The MACD line has crossed below the Signal line.

That only describes how the averages moved. It says nothing certain about the next bar.

Technical details

For readers who want the exact rules. CBc MACD is computed on KAGAMI's servers. The chart in your browser only draws the values it gets back.

The calculation

On the closing prices of the chart's market and timeframe:

  1. The EMA (exponential moving average) of length n: α = 2 ÷ (n + 1). The first value comes on the n-th bar: the plain average of the first n closes. After that: EMA = α × close + (1 − α) × EMA of the bar before. There is no value before the n-th bar.
  2. MACD line = EMA(Fast) − EMA(Slow), on every bar where both EMAs have a value.
  3. Signal line = EMA(Signal) of the MACD values, counting only bars that have a MACD value. Its first value is the plain average of the first Signal MACD values.
  4. Histogram = MACD − Signal, on every bar where both have a value.
  5. Every value is rounded to 6 decimals.
A daily chart of AAPL with two averages, EMA 12 in blue and EMA 26 in grey, and the space between them shaded. Below, the CBc MACD pane: the MACD line rises while the space between the two averages grows.A daily chart of AAPL with two averages, EMA 12 in blue and EMA 26 in grey, and the space between them shaded. Below, the CBc MACD pane: the MACD line rises while the space between the two averages grows.
AAPL, daily candles, with EMA 12 and EMA 26 on the price and CBc MACD 12-26-9 below. 1 — on one bar, the gap between EMA 12 and EMA 26. 2 — that gap, 5.99, is the MACD line on the same bar. 3 — the column is MACD minus Signal: 5.99 − 4.39 = 1.60. It is as tall as the space between the two lines above it.

With the default settings, the MACD line starts on the 26th bar the server reads. The Signal line and the Histogram start on the 34th (26 + 9 − 1).

Inputs

NameDefaultRangeWhat it does
Fast12whole numbers, 1 to 500Bars in the fast EMA
Slow26whole numbers, 1 to 500Bars in the slow EMA
Signal9whole numbers, 1 to 500Bars in the EMA of the MACD line

Nothing checks that Fast is smaller than Slow. The server computes exactly what you ask for. A value that is not a number above 0 is replaced by its default.

Lines and colours

PlotStyleDark themeLight theme
MACDline, 2 pixelsindigo #6366F1indigo #4F46E5
Signalline, 1 pixelgold #F59E0Bgold #D97706
Histogram, at or above 0columns, 15 % transparencygreen #22C55Egreen #16A34A
Histogram, below 0columns, 15 % transparencyred #EF4444red #DC2626

The colour of a column only depends on its sign. When you switch between the dark and light theme, KAGAMI re-colours the plots.

How the chart gets the values

  • The chart computes nothing for CBc MACD. For each of its three plots, it asks KAGAMI's servers for a series. The request names the chart's market, its timeframe and the three inputs.
  • The server reads the bars the chart asks for, plus 300 bars before them. It never reads more than 2,000 bars at once. It computes the values and sends one value per bar.
  • Bars without a value (at the start) are left out. Each plot starts where its values start.
  • The chart lines each value up with its candle.
  • When you change an input, the chart sends new requests with the new numbers. The old values are replaced.

When values change

  • The newest bar is still forming. Its values are computed again each time the chart refreshes: about every 15 seconds, or every 5 seconds on a seconds chart. This happens only while the page is visible.
  • The bar that just closed gets its final values on the next refresh. After that, they stay.
  • The far left can shift a little. Each request starts its averages at the first bar it read. So two requests can give slightly different values for the very oldest bars. With the default settings, the 300 extra bars make this difference far too small to see. With very long settings, it can be visible.

Timeframes

  • CBc MACD works on every timeframe. It is computed on the bars of the timeframe on screen.
  • Seconds timeframes (1, 5, 10, 15 and 30 seconds) exist for crypto only. The server computes on the real second bars. They reach back about 24 hours.
  • US stocks follow US market hours, 09:30 to 16:00 New York time. Crypto trades all day, every day (times in UTC).
  • The same settings mean different time spans. Slow 26 is 26 minutes on a 1-minute chart, but 26 days on a daily chart.

Some links that open KAGAMI already ask for MACD. KAGAMI's servers then compute the same values, with the same maths. The chart draws them in a different way:

  • three separate entries in the legend, not one;
  • the MACD line in indigo, 1 pixel, and the Signal line in gold;
  • the Histogram as a grey shaded area (#8B90A8 dark, #5B607A light), not green and red columns;
  • no Fast, Slow or Signal settings: the numbers come from the link.

Differences from the chart's built-in version

The Indicators list also has the chart's own MACD. With its default settings, it uses the same maths: EMAs started with a plain average, and a Signal line over the MACD values only. The differences:

  • Where it is computed. CBc MACD: on KAGAMI's servers. MACD: in your browser.
  • Where it starts. CBc MACD: 300 bars before what the chart asks for. MACD: at the first bar the chart loaded. Only the oldest values can differ.
  • Inputs. CBc MACD has Fast, Slow and Signal (1 to 500). MACD has Fast Length and Slow Length (1 to 2,000), Source (the close at first), Signal Length (1 to 50), Oscillator MA Type and Signal Line MA Type (SMA, EMA or WMA; EMA at first), and Other Symbol.
  • Line colours. CBc MACD: an indigo MACD line, 2 pixels, and a gold Signal line. MACD: a blue MACD line (#2196F3) and an orange Signal line (#FF6D00).
  • Column colours. CBc MACD: two colours, by sign only. MACD: four shades. Above 0: a strong green while the column grows, a pale green otherwise. At or below 0: a pale red while the column rises, a strong red (#FF5252) otherwise.
  • Rounding. CBc MACD rounds every value to 6 decimals.
  • Refresh. CBc MACD asks the server again on each refresh of the chart. MACD is computed again in your browser whenever the candles update.

Edge cases

  • Too few bars. The MACD line needs Slow bars (or Fast, if larger). The Signal line and the columns need that many plus Signal − 1 more. Before that, nothing is drawn.
  • Very large settings. The server reads at most 2,000 bars at once, and often fewer. With very large Slow and Signal, the Signal line and the columns may stay empty.
  • Fast equal to Slow. Both averages are the same, so MACD is 0 on every bar.
  • Fast bigger than Slow. The MACD line has the opposite sign of the usual one.
  • Flat prices. If the price does not move, both averages meet, and MACD, Signal and the columns go to 0. A column at exactly 0 counts as green.
  • Gaps. Nights and weekends do not count as bars. The bar after a gap is simply the next bar, often with a big move.
  • No data. If KAGAMI cannot get the market's bars, nothing is drawn. For example, US stock charts need a connected broker; see KAGAMI charts.