作者:凌波

MACD Oscillator Indicator — Complete Implementation Specification

Based on Lingbo (凌波), MACD Oscillator Indicator Upgraded Edition (振荡指标MACD升级版)


Table of Contents

  1. Overview

  2. MACD Construction and Components

  3. Histogram Analysis

  4. Zero-Line Crossovers

  5. MACD Divergence

  6. Signal Line Crossovers

  7. Multi-Timeframe MACD Analysis

  8. MACD Combined with Volume

  9. MACD Combined with Moving Averages

  10. MACD Combined with Other Indicators

  11. A-Share Specific MACD Applications

  12. Common MACD Traps and Failures

  13. Advanced MACD Patterns

  14. Key Quotes


1. Overview

Lingbo is a Chinese technical analysis author known for practical, system-oriented approaches to trading A-shares. MACD Oscillator Indicator Upgraded Edition provides a comprehensive treatment of the Moving Average Convergence Divergence indicator that goes far beyond the standard textbook description of "buy when MACD crosses above signal, sell when it crosses below."

The book treats MACD not as a standalone signal generator but as a tool for reading the momentum structure of price action. Lingbo's key contribution is systematizing MACD analysis into a hierarchy: zero-line position defines trend, histogram shape defines momentum, and signal-line crossovers define timing — with each level filtered by the one above it.

1.1 Why MACD for A-Shares

Lingbo argues MACD is particularly suited to A-share trading because:

1.2 The Three Dimensions of MACD

Dimension Component What It Reveals
Trend MACD line position relative to zero line Overall trend direction and strength
Momentum Histogram bars (height and direction of change) Rate of change of trend strength
Timing Signal line crossovers Entry and exit points within the trend

2. MACD Construction and Components

2.1 Mathematical Foundation

The MACD indicator consists of three components derived from exponential moving averages (EMAs):

Lingbo notes that the standard parameters (12, 26, 9) work well for daily charts in A-shares. He cautions against excessive parameter optimization, which leads to curve-fitting rather than genuine improvement.

2.2 EMA Calculation

PSEUDOCODE: EMA Calculation
────────────────────────────
function EMA(prices, period):
    multiplier = 2 / (period + 1)
    ema = prices[0]    // Initialize with first price
    for i in 1..len(prices):
        ema = (prices[i] - ema) * multiplier + ema
    return ema

2.3 Parameter Adjustments

While the default (12, 26, 9) is recommended for most purposes, Lingbo discusses specific adjustments:


3. Histogram Analysis

3.1 The Histogram as Momentum Gauge

The histogram is the most informative component of MACD according to Lingbo. It represents the distance between the MACD line and signal line, and its behavior reveals momentum shifts before price confirms them:

Rising histogram (bars getting taller): Momentum is accelerating in the direction of the trend. Whether above or below zero, taller bars mean the trend is strengthening.

Falling histogram (bars getting shorter): Momentum is decelerating. The trend may still continue, but its force is waning. This is the earliest warning of a potential reversal.

Histogram crossing zero: The MACD line has crossed the signal line — this is the actual crossover signal. But by reading histogram contraction beforehand, the trader is prepared.

3.2 Histogram Color Patterns

In Chinese trading software, the histogram is typically displayed as:

3.3 The "Mountain and Valley" Pattern

Lingbo introduces the concept of histogram "mountains" (connected positive bars forming a hump) and "valleys" (connected negative bars forming a trough):


4. Zero-Line Crossovers

4.1 Zero-Line as Trend Divider

The zero line is the most important reference point in MACD analysis. When the MACD line (DIF) is above zero, the 12-period EMA is above the 26-period EMA, indicating an uptrend. Below zero indicates a downtrend.

4.2 Zero-Line Crossover Signals

Bullish zero-line crossover: DIF crosses above zero from below. This confirms a shift from downtrend to uptrend. Lingbo considers this one of the highest-quality MACD signals because it confirms a genuine trend change rather than a mere pullback bounce.

Bearish zero-line crossover: DIF crosses below zero from above. Confirms shift from uptrend to downtrend. When this occurs after a prolonged uptrend, it is a strong warning to exit long positions.

4.3 Zero-Line Rejection

Bullish rejection: DIF pulls back toward zero during an uptrend but does not cross below, then turns back up. This indicates the uptrend is intact and the pullback was a buying opportunity.

Bearish rejection: DIF rallies toward zero during a downtrend but does not cross above, then turns back down. The downtrend is intact; rallies should be sold.

PSEUDOCODE: Zero-Line Analysis
────────────────────────────────
function analyze_zero_line(dif_series):
    current = dif_series[-1]
    previous = dif_series[-2]
    trend = "bullish" if current > 0 else "bearish"

    // Zero-line crossover
    if previous < 0 and current > 0:
        return "BULLISH_CROSSOVER — trend turning up"
    if previous > 0 and current < 0:
        return "BEARISH_CROSSOVER — trend turning down"

    // Zero-line rejection (bullish)
    if trend == "bullish":
        recent_low = min(dif_series[-10:])
        if recent_low > -0.05 * abs(max(dif_series[-30:])):
            if current > previous:
                return "BULLISH_REJECTION — pullback within uptrend, buying opportunity"

    // Zero-line rejection (bearish)
    if trend == "bearish":
        recent_high = max(dif_series[-10:])
        if recent_high < 0.05 * abs(min(dif_series[-30:])):
            if current < previous:
                return "BEARISH_REJECTION — rally within downtrend, selling opportunity"

    return "NEUTRAL"

5. MACD Divergence

5.1 Divergence as the Strongest Signal

Lingbo considers divergence the most reliable and profitable signal that MACD produces. Divergence occurs when price makes a new extreme but MACD does not confirm it, indicating that momentum is failing to support the price move.

5.2 Bullish Divergence

Price makes a lower low but MACD (either DIF or histogram) makes a higher low. This signals that selling pressure is diminishing and a reversal may be imminent.

Conditions for high-quality bullish divergence:

  1. Price is in a clear downtrend (not just a minor dip)
  2. The divergence occurs near a significant support level
  3. Volume declines on the second low (selling exhaustion)
  4. The histogram valley is clearly shallower on the second low

5.3 Bearish Divergence

Price makes a higher high but MACD makes a lower high. Buying pressure is waning despite higher prices.

Conditions for high-quality bearish divergence:

  1. Price is in a mature uptrend (multiple waves up already)
  2. The divergence occurs after a significant price advance
  3. Volume declines on the second high
  4. The histogram mountain is clearly shorter on the second high

5.4 Triple Divergence

When divergence occurs three times consecutively (price makes three higher highs with MACD making three lower highs, or vice versa), the signal is extremely strong. Lingbo considers triple divergence one of the most reliable reversal signals in technical analysis.

5.5 Hidden Divergence

Hidden bullish divergence: In an uptrend, price makes a higher low but MACD makes a lower low. This signals trend continuation — the pullback is an opportunity to buy within the uptrend.

Hidden bearish divergence: In a downtrend, price makes a lower high but MACD makes a higher high. Trend continuation to the downside — rallies should be sold.


6. Signal Line Crossovers

6.1 Golden Cross and Death Cross

Golden cross: DIF crosses above DEA. Bullish signal. Quality depends on where it occurs relative to the zero line.

Death cross: DIF crosses below DEA. Bearish signal. Quality depends on position relative to zero line.

6.2 Crossover Quality Hierarchy

Lingbo ranks crossover signals by quality:

Crossover Type Location Quality Action
Golden cross Above zero line Highest Strong buy — trend continuation
Golden cross Near zero line (crossing up) High Buy — new trend beginning
Golden cross Far below zero line Medium Potential bottom, but trend still down
Death cross Below zero line Highest Strong sell — trend continuation down
Death cross Near zero line (crossing down) High Sell — trend turning down
Death cross Far above zero line Medium Pullback warning, trend may still be up

6.3 The "Kissing" Cross

A special pattern where DIF and DEA nearly touch (or briefly touch) but do not complete a full crossover, then diverge again in the original direction. This "kissing" pattern is a strong continuation signal: the trend tested but held.


7. Multi-Timeframe MACD Analysis

7.1 The Timeframe Hierarchy

Lingbo's multi-timeframe approach uses three levels:

The cardinal rule: never trade against the higher timeframe MACD trend.

7.2 Multi-Timeframe Alignment

PSEUDOCODE: Multi-Timeframe MACD Decision
───────────────────────────────────────────
weekly_macd = calculate_macd(weekly_prices)
daily_macd = calculate_macd(daily_prices)
hourly_macd = calculate_macd(hourly_prices)

// Determine weekly trend
if weekly_macd.dif > 0 and weekly_macd.histogram > previous_histogram:
    weekly_trend = "STRONG_UP"
elif weekly_macd.dif > 0:
    weekly_trend = "UP"
elif weekly_macd.dif < 0 and weekly_macd.histogram < previous_histogram:
    weekly_trend = "STRONG_DOWN"
else:
    weekly_trend = "DOWN"

// Only take long signals when weekly is UP or STRONG_UP
if weekly_trend in ["UP", "STRONG_UP"]:
    if daily_macd.golden_cross() or daily_macd.bullish_divergence():
        if hourly_macd.histogram_turning_up():
            signal = "BUY"
            confidence = "HIGH" if weekly_trend == "STRONG_UP" else "MEDIUM"

// Only take short/sell signals when weekly is DOWN or STRONG_DOWN
if weekly_trend in ["DOWN", "STRONG_DOWN"]:
    if daily_macd.death_cross() or daily_macd.bearish_divergence():
        signal = "SELL / AVOID"

7.3 Timeframe Conflicts

When timeframes conflict (e.g., weekly bullish but daily bearish), Lingbo advises:


8. MACD Combined with Volume

8.1 Volume Confirmation Rules

MACD signals are significantly more reliable when confirmed by volume:

8.2 Volume-MACD Divergence

A separate form of divergence exists between volume and MACD:


9. MACD Combined with Moving Averages

9.1 MA Support/Resistance with MACD Timing

Lingbo recommends using moving averages (typically 20-day and 60-day) as support/resistance levels, then using MACD to time entries:

9.2 Moving Average Alignment + MACD

When short-term MAs are above long-term MAs (bullish alignment) and MACD is above zero with rising histogram, this represents maximum trend strength. Lingbo calls this the "triple confirmation" state — MA alignment, MACD trend, and MACD momentum all in agreement.


10. MACD Combined with Other Indicators

10.1 MACD + KDJ (Stochastic)

KDJ provides overbought/oversold readings that MACD lacks:

10.2 MACD + RSI

RSI provides momentum extremes:

10.3 MACD + Bollinger Bands

Bollinger Bands provide volatility context:


11. A-Share Specific MACD Applications

11.1 Board-Specific Behavior

Lingbo observes that MACD behaves differently across A-share market segments:

11.2 Opening and Closing Auction Effects

A-shares have significant auction effects. Lingbo warns that intraday MACD on timeframes shorter than 30 minutes can be distorted by the opening and closing auction mechanisms. Use 60-minute or longer for intraday MACD.

11.3 Limit-Up and Limit-Down Days

When a stock hits the daily price limit (涨停/跌停), MACD signals should be interpreted with caution:

11.4 Policy-Driven Market Moves

In A-shares, sudden policy announcements can cause gap moves that invalidate MACD signals. Lingbo advises treating any gap exceeding 3% as a "reset event" that requires re-analysis of the MACD structure from scratch.


12. Common MACD Traps and Failures

12.1 Whipsaw in Ranging Markets

MACD performs poorly in sideways, trendless markets. The DIF and DEA repeatedly cross each other around the zero line, generating buy and sell signals that both fail. Lingbo's solution: when the histogram bars are very small and alternating rapidly, stand aside.

12.2 Lagging Nature

MACD is inherently a lagging indicator. It confirms trend changes after they have begun, not before. Divergence provides some leading quality, but even divergence requires the second peak or trough to form before it can be identified.

12.3 False Divergence

Not all apparent divergences lead to reversals. In very strong trends, MACD can show multiple divergences while price continues in the trend direction. Lingbo calls these "divergence traps" and advises using volume and price structure (not just MACD alone) to confirm divergence signals.

12.4 Crossover Frequency Filter

Lingbo recommends a minimum time filter between crossovers: if a golden cross is followed by a death cross within 3 bars, treat both as noise rather than genuine signals. Quality crossovers typically last at least 5-8 bars.


13. Advanced MACD Patterns

13.1 The "Underwater Golden Cross"

A golden cross that occurs below the zero line. This is a bottom-fishing signal with moderate reliability. It indicates that downward momentum is slowing, but the overall trend is still bearish. Use only as a preliminary signal — wait for zero-line crossover for full confirmation.

13.2 The "Second Golden Cross Above Zero"

After a golden cross above zero, DIF pulls back to DEA (or slightly below) and then crosses up again. This second golden cross above zero is Lingbo's highest confidence buy signal: the uptrend is established, the pullback was minor, and momentum is resuming.

13.3 MACD "Wing" Pattern

When the histogram forms two peaks of similar height separated by a pullback to near zero (but not crossing zero), this creates a visual "wing" pattern. This indicates strong, sustained momentum and suggests the trend will continue.

13.4 Zero-Line "Trampoline"

DIF briefly touches or slightly penetrates the zero line during a pullback in an uptrend, then bounces strongly back above zero. Like a trampoline effect, the brief zero-line touch provides the "spring" for the next leg up.


15. Key Quotes

"MACD is not a signal machine — it is a momentum language. Learn to read it and the market will speak to you."

"The zero line is the equator of the MACD world. Above it, bulls are in control. Below it, bears dominate. The most important decisions happen at the crossing."

"Divergence is the market whispering that the trend is lying. Listen to the whisper before it becomes a scream."

"A golden cross above the zero line is worth three golden crosses below it. Position within the trend matters more than the crossover itself."

"The histogram tells you what is happening now. The DIF and DEA tell you what has happened. Only divergence hints at what will happen next."

"In a ranging market, MACD will hurt you. The first skill of a MACD trader is recognizing when not to trade."

"Multi-timeframe alignment is not optional — it is the foundation. Trading a daily golden cross against a weekly downtrend is fighting the current."

"Volume is the truth serum of any MACD signal. A crossover without volume is a promise without commitment."