Systemicbeta

Moving Average Convergence Divergence

systemic:core-macdIndicators

Inputs

NameTypeDescription
Short Window / Short EMAWhole numberThe number of bars for the **fast EMA** in the MACD calculation.
Long Window / Long EMAWhole numberThe number of bars for the **slow EMA** in the MACD calculation.
Signal Window / Signal LineWhole numberThe window of the **Signal Line EMA**, which this module does not output and which does not change the MACD Line.
PriceNumber seriesThe price series used for the MACD calculation.

Outputs

NameTypeDescription
MACDNumber seriesThe **MACD Line**: the fast exponential moving average minus the slow one.

Cost

6
credits per run
1,000
bars

0.205 + 0.00574·n credits for n bars, rounded up. The marks are each plan's limit of bars.

The MACD (Moving Average Convergence Divergence) is one of the best-known momentum indicators in technical analysis. Gerald Appel created it in the late 1970s. It is still widely used because it combines trend-following and momentum analysis in a single measure.

What this module outputs: The MACD Line: the difference between a fast and a slow EMA. To build a complete MACD with Signal Line and Histogram, combine this module with an EMA module and a Subtract module.

MACD Line=EMAfast−EMAslow\text{MACD Line} = \text{EMA}_{\text{fast}} - \text{EMA}_{\text{slow}}

The Intuition Behind MACD

When a fast moving average is above a slow moving average, recent prices are higher than the longer-term average: bullish momentum. When it is below, recent prices are lower: bearish momentum.

MACD measures the distance between the two averages.

flowchart LR
    subgraph Price["Price Action"]
        P["Closing Prices"]
    end
    
    subgraph EMAs["Exponential Moving Averages"]
        F["Fast EMA (12)"]
        S["Slow EMA (26)"]
    end
    
    subgraph Output["MACD Line"]
        M["Fast − Slow"]
    end
    
    P --> F
    P --> S
    F --> M
    S --> M

Interpreting MACD Values

MACD ValueMeaning
Positive (+)Fast EMA > Slow EMA → Bullish momentum
Negative (−)Fast EMA < Slow EMA → Bearish momentum
RisingMomentum is strengthening
FallingMomentum is weakening
Crossing ZeroTrend direction may be reversing

The Zero Line

The zero line is where the fast and slow EMAs are equal. A cross above or below zero often signals a trend change:

flowchart TD
    subgraph Above["MACD > 0"]
        A1["Fast EMA above Slow EMA"]
        A2["Uptrend momentum"]
    end
    
    subgraph Cross["MACD = 0"]
        C1["EMAs are equal"]
        C2["Potential trend change"]
    end
    
    subgraph Below["MACD < 0"]
        B1["Fast EMA below Slow EMA"]
        B2["Downtrend momentum"]
    end
    
    Above --> Cross --> Below

Configuration Parameters

ParameterStandard valueDescription
Short Window12Fast EMA window
Long Window26Slow EMA window
Signal Window9Window of the Signal Line. It does not change the MACD Line

Why 12-26-9?

The module has no built-in defaults. These standard values were set by Gerald Appel for daily stock charts:

  • 12 days ≈ Two trading weeks (short-term trend)
  • 26 days ≈ One trading month (medium-term trend)
  • 9 days ≈ Signal Line smoothing

Alternative Configurations

Market ConditionShortLongRationale
High Volatility817More responsive to rapid changes
Low Volatility1939Filters out noise
Crypto (24/7)1226Standard works well
Weekly Charts1226Same proportions, larger timeframe

Building a Complete MACD System

This module outputs only the MACD Line. To build a full MACD, combine it with other modules:

flowchart TD
    subgraph Step1["1. MACD Module"]
        M["MACD Line = EMA₁₂ − EMA₂₆"]
    end
    
    subgraph Step2["2. Add EMA Module"]
        E["Signal Line = EMA₉ of MACD"]
    end
    
    subgraph Step3["3. Add SUB Module"]
        H["Histogram = MACD − Signal"]
    end
    
    subgraph Signals["Trading Signals"]
        S1["Crossovers"]
        S2["Zero-line crosses"]
        S3["Divergence"]
    end
    
    Step1 --> Step2 --> Step3 --> Signals

Complete MACD Components

ComponentFormulaWhat It Shows
MACD LineEMA₁₂ − EMA₂₆Momentum direction
Signal LineEMA₉ of MACDSmoothed momentum
HistogramMACD − SignalMomentum acceleration

Trading Strategies

Strategy 1: Zero-Line Crossover

The simplest MACD signal: MACD crosses zero.

SignalConditionInterpretation
BullishMACD crosses above 0Short-term trend now above long-term
BearishMACD crosses below 0Short-term trend now below long-term

Strength: These signals are less frequent but more reliable than Signal Line crossovers.

Strategy 2: MACD Direction

Watch whether MACD is rising or falling, whatever its level.

MACD BehaviorInterpretation
Rising from deeply negativeBearish momentum slowing, potential reversal
Falling from positiveBullish momentum weakening
Accelerating upwardStrong bullish pressure

Strategy 3: Divergence Detection

Compare the direction of MACD with the direction of price. A divergence often comes before a reversal.

TypePrice ActionMACD ActionMeaning
Bullish DivergenceLower lowsHigher lowsSelling exhaustion
Bearish DivergenceHigher highsLower highsBuying exhaustion

MACD vs. Other Indicators

IndicatorMeasuresMACD Advantage
RSIOverbought/OversoldMACD shows trend direction
StochasticPrice position in rangeMACD works in trends, not just ranges
ADXTrend strength onlyMACD shows direction + momentum
Simple MA CrossoverTrend onlyMACD is smoother (uses EMAs)

Strengths

AspectBenefit
Dual natureCaptures both trend and momentum
Visual clarityEasy to interpret rising/falling patterns
VersatilityWorks across timeframes and asset classes
Well-establishedDecades of trader experience and research

Limitations

AspectChallenge
LaggingBased on moving averages—inherently delayed
False signalsWhipsaws common in ranging/choppy markets
Not boundedUnlike RSI, no overbought/oversold levels
Requires confirmationBest used with other indicators

Combining MACD with Other Modules

CombinationPurpose
MACD + EMACreate Signal Line for crossover signals
MACD + RSIConfirm: MACD bullish + RSI not overbought = stronger signal
MACD + ATRUse ATR for position sizing based on volatility
MACD + VolumeVolume spike + MACD cross = higher confidence
MACD + Bollinger BandsVolatility squeeze + MACD cross = breakout signal

Historical Context

Gerald Appel introduced MACD in his 1979 book "The Moving Average Convergence Divergence Trading Method". It was designed for stocks, but it is now used across asset classes: forex, crypto, commodities and indices.

The indicator has been in use for over 45 years. It captures a basic market pattern: short-term momentum compared with the longer-term trend.


Data Alignment in Systemic

The MACD module takes one price series, price_data. The three window parameters (Short, Long, Signal) are constants.

Single-Input Behavior

The price_data input usually comes directly from an asset data source. It can also be the output of another module:

  • The output has one value per bar of the input
  • No alignment is needed, because only one series is used

Parameter Constants

All three window parameters (Short, Long, Signal) are constants:

  • Each is one fixed value for the whole run
  • This keeps the EMA calculation the same across the whole series

Data Length Requirements

The run fails if the price series has fewer bars than:

Minimum bars=max⁡(Short Window,Long Window,Signal Window)\text{Minimum bars} = \max(\text{Short Window}, \text{Long Window}, \text{Signal Window})

With the standard settings (12, 26, 9), you need at least 26 bars.


Missing Data

Both EMAs use only the bars that have data:

  • Closed-market gaps (e.g. weekends) stay empty and are skipped. A missing input bar gives an empty output on that bar. It never repeats the previous MACD value and is never 0. The EMAs treat the next bar with data (e.g. Monday) as the bar right after the last bar with data (Friday), not as several calendar days later.
  • Warm-up is empty, never 0.0. The first long_window − 1 bars with data have no MACD value, so the warm-up cannot be misread as a zero-line crossover.

Indicator Profile

This chart compares how useful MACD is for stocks and for cryptocurrencies:

quadrantChart
    title MACD Indicator Profile
    x-axis Low Popularity --> High Popularity
    y-axis Low Reliability --> High Reliability
    quadrant-1 High potential  
    quadrant-2 Established leaders
    quadrant-3 Niche tools
    quadrant-4 Popular but risky
    MACD - Stocks: [0.90, 0.75]
    MACD - Crypto: [0.85, 0.65]

Dimension Ratings

DimensionStocksCryptoNotes
Popularity9.0/108.5/10One of the most widely used indicators globally. Standard on every trading platform.
Reliability7.5/106.5/10Reliable in trending markets. Crypto's higher volatility increases false signals.
Complexity4.0/104.0/10Conceptually simple (EMA difference). Most traders can interpret it quickly.
Versatility8.5/108.0/10Works across all timeframes and asset classes. The standard settings are widely applicable.
Recent Interest7.5/107.0/10Steady classic indicator. Continues to appear in research and trading education.

Further Reading

Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5