What Are the MACD Line, Signal Line, and Histogram?

AAPL candlesticks with EMA 12 and EMA 26 above MACD line signal line and histogram calculated in Python

In Phase 3-12, we deliberately stopped after one line.

MACD line
=
EMA 12
-
EMA 26

That was enough to understand where MACD begins.

But a standard MACD chart usually shows three things:

MACD line
Signal line
Histogram

They are not three unrelated indicators.

Each one is built from the previous one.

Close prices
     ↓
EMA 12 - EMA 26
     ↓
MACD line
     ↓
smooth the MACD line
     ↓
Signal line
     ↓
MACD - Signal
     ↓
Histogram

1. Start with the MACD Line We Already Know

The first component is unchanged from the previous MACD lesson.

MACD line
=
fast EMA
-
slow EMA

With the common settings:

MACD line
=
EMA 12
-
EMA 26

A positive value means the faster EMA is above the slower EMA. A negative value means it is below.

We do not need to relearn that calculation.

2. Now Ask a New Question

The MACD line can move up and down quickly.

What if we smooth the MACD line itself?

MACD values
     ↓
apply an EMA
     ↓
smoother MACD values

That smoother line is called the signal line.

3. The Signal Line Reuses a Calculation We Already Know

A common MACD signal line is a 9-period EMA of the MACD line.

Signal line
=
EMA 9 of MACD

Notice what changed.

Earlier, our EMA input was price:

Close prices
→ EMA

Now the input is another indicator:

MACD values
→ EMA

The EMA calculation itself does not change.

4. Why Smooth an Indicator?

An EMA summarizes a sequence while giving more influence to recent values.

When we apply it to MACD:

MACD line
→ faster changing relationship

Signal line
→ smoother view of that relationship

This creates two time scales again.

But now they are two time scales of the MACD relationship, not two moving averages of price.

5. Reuse the Frozen EMA Block

We do not need a new signal_line() function.

We already have:

exponential_moving_average()

So we reuse it:

signal_values, signal_alpha = exponential_moving_average(
    values=macd_values,
    span=9,
)

This is an important programming and learning idea.

known function
+
new input
=
new use

6. The Histogram Is One More Difference

We now have:

MACD line
Signal line

The histogram measures the distance between them.

Histogram
=
MACD line
-
Signal line

That subtraction is the one main new Learning Block in this lesson.

7. Read the Histogram Directly from the Formula

Suppose:

MACD = 2.0
Signal = 1.4

Then:

Histogram
=
2.0 - 1.4
=
+0.6

Positive histogram:

MACD line
is above
Signal line

Now suppose:

MACD = -1.2
Signal = -0.8

Then:

Histogram
=
-1.2 - (-0.8)
=
-0.4

Negative histogram:

MACD line
is below
Signal line

8. Histogram Zero Is a Different Event from MACD Zero

This distinction is easy to miss.

MACD = 0
means
EMA 12 = EMA 26

But:

Histogram = 0
means
MACD line = Signal line

These are not the same crossing.

Price EMA crossover
      ↓
MACD crosses zero


MACD / Signal crossover
      ↓
Histogram crosses zero

Keeping these two zero lines separate prevents a common conceptual mistake.

9. Work Through the Same Tiny Example Again

We can reuse the toy example from Phase 3-12.

Prices:
100, 102, 101, 104, 103, 106

Fast EMA span = 3
Slow EMA span = 5

The previous lesson gave the final MACD value:

MACD ≈ 0.885288

For a small hand example, use:

Signal EMA span = 3

Apply our familiar EMA function to the MACD sequence. The final signal value becomes approximately:

Signal ≈ 0.676826

Now subtract:

Histogram
=
0.885288
-
0.676826

≈ 0.208462

The histogram is positive because the MACD line is above its signal line.

10. Build the Histogram from Scratch

The new function stays small:

def macd_histogram(macd_values, signal_values):
    histogram_values = []

    for macd_value, signal_value in zip(
        macd_values,
        signal_values,
    ):
        histogram = float(macd_value) - float(signal_value)
        histogram_values.append(histogram)

    return histogram_values

The code mirrors the formula:

MACD
-
Signal
=
Histogram

11. Validate Before Using Real Market Data

The runnable Python file checks the tiny example first.

expected last MACD
≈ 0.885288

expected last Signal
≈ 0.676826

expected last Histogram
≈ 0.208462

If any value does not match, the script stops before downloading AAPL data.

hand example
     ↓
known EMA block
     ↓
known MACD block
     ↓
new Histogram block
     ↓
same expected values
     ↓
then real data

12. Why This Article Uses Only Two Chart Panels

Phase 3-12 showed a broad five-panel view so we could see MACD beside Momentum, ROC, and RSI.

This lesson has a narrower question.

So we zoom in.

Panel 1
Candles + EMA 12 + EMA 26

Panel 2
MACD line + Signal line + Histogram

We still reuse create_stacked_panels(). We simply ask it for two panels.

Reusable code does not mean every chart must keep getting larger.

13. What Does Each Component Measure?

MACD line
=
EMA 12 - EMA 26

Question:
How far apart are the two
smoothed price levels?


Signal line
=
EMA 9 of MACD

Question:
What is a smoother view
of the MACD line?


Histogram
=
MACD - Signal

Question:
How far is MACD
from its smoother signal line?

The three components are a chain.

price relationship
     ↓
MACD

smooth that relationship
     ↓
Signal

compare current relationship
with its smoother version
     ↓
Histogram

14. What Does a Growing Positive Histogram Mean?

Suppose the histogram changes:

+0.2
+0.4
+0.7

That means:

MACD - Signal
is becoming more positive

In other words, the MACD line is moving farther above the signal line.

It does not mathematically guarantee:

the next price must rise

The histogram describes a changing relationship between two derived series.

15. What Does a Shrinking Positive Histogram Mean?

Suppose:

+0.8
+0.5
+0.2

The histogram is still positive.

So MACD is still above Signal.

But the distance between them is shrinking.

positive
does not mean
increasing

negative
does not mean
decreasing

Sign and slope answer different questions.

16. A Signal-Line Cross and a Zero Cross Are Not the Same Signal

A MACD chart can show two different crossing events.

Event A

MACD crosses zero
→ fast EMA crosses slow EMA


Event B

MACD crosses Signal
→ Histogram crosses zero

If we later test trading rules, we must define which event we mean.

Saying only:

MACD crossed

is not precise enough for reproducible research.

17. Initialization Still Matters

Alphesta keeps the EMA block already taught in earlier lessons.

It starts an EMA with the first available input value.

For the signal line, that means:

first Signal value
=
first available MACD value

Some libraries use different warm-up conventions.

Therefore, early MACD, signal, and histogram values may differ between implementations.

That does not change the conceptual chain:

EMA fast - EMA slow
→ MACD

EMA of MACD
→ Signal

MACD - Signal
→ Histogram

18. The Three Components Are Still Not a Trading Strategy

A positive histogram means:

MACD
is above
Signal

It does not automatically mean:

buy

A histogram crossing below zero means:

MACD
crossed below
Signal

It does not automatically mean:

sell

Those would be strategy hypotheses. They belong in later rule-definition and backtest phases.

19. Change One Thing Yourself

Keep:

macd_fast_span = 12
macd_slow_span = 26

Start with:

macd_signal_span = 9

Then try:

macd_signal_span = 5

Ask:

Does Signal follow MACD more closely?

Does the Histogram become smaller
more often?

Do crossings happen sooner?

Then try:

macd_signal_span = 15

Ask the opposite questions.

The goal is not to optimize MACD yet. The goal is to understand what the signal smoothing period changes.

20. One Historical Question Is Now Worth Asking

We now understand the mechanics of the standard MACD family.

two EMA time scales
→ MACD

smooth MACD
→ Signal

compare MACD with Signal
→ Histogram

That gives us enough technical background to ask a different question:

Why did Gerald Appel build
this structure in the first place?

If you want to understand the historical problem, design logic, later adoption, empirical evidence, and common misuse, read Why Did Gerald Appel Create MACD? The Search for a Simpler Trend-Momentum Indicator.

That Origin & Philosophy companion does not replace the Phase 3 Core Path. It helps explain why the tool exists before we test rules with it.

Check Your Understanding

  • The MACD line is the fast EMA minus the slow EMA.
  • The signal line is an EMA of the MACD line.
  • The common signal span is 9 periods.
  • The histogram is the MACD line minus the signal line.
  • MACD = 0 means the fast and slow EMA values are equal.
  • Histogram = 0 means the MACD and signal line values are equal.
  • A positive histogram means MACD is above Signal.
  • A shrinking positive histogram is still positive, but the two lines are getting closer.
  • The same EMA function can operate on price or on another derived series.
  • MACD components describe relationships; they do not automatically define trades.

What You Just Learned

Close
  ↓
EMA 12      EMA 26
   \          /
      subtract
         ↓
       MACD
         ↓
       EMA 9
         ↓
       Signal
         ↓
MACD - Signal
         ↓
     Histogram

If one idea stays in your head after this lesson, let it be this:

The MACD line, signal line, and histogram are not three mysterious signals. They are one chain of familiar transformations.

Sources