Systemicalpha

Directional Movement Index

systemic:core-dmiIndicatorsfunction1 cr

Inputs

NameTypeDescription
WindowintegerThe number of periods (e.g., days) over which the DMI is calculated.
Price HighfloatarrayThe highest price of the asset for the given time period.
Price LowfloatarrayThe lowest price of the asset for the given time period.
Price ClosefloatarrayThe closing price of the asset for the given time period.

Outputs

NameTypeDescription
Dmifloatarray- **Description**; The DMI is an indicator that combines the +DI and -DI to determine the overall strength of a trend. It is often used in conjunction with the Average Directional Index (ADX) to confirm trend direction and strength.
+DIfloatarray- **Description**; The +DI measures the strength of upward price movements. It indicates the extent to which the price is moving up compared to the previous period.
-DIfloatarray- **Description**; The -DI measures the strength of downward price movements. It indicates the extent to which the price is moving down compared to the previous period.

Overview

The Directional Movement Index (DMI), developed by J. Welles Wilder Jr., is a cornerstone of technical analysis for identifying the strength and direction of market trends. DMI is widely used in both traditional securities (stocks, ETFs, futures) and cryptocurrencies to distinguish trending from ranging markets and to generate actionable trading signals. It is composed of three main elements:

  • +DI (Positive Directional Indicator): Measures upward trend strength
  • -DI (Negative Directional Indicator): Measures downward trend strength
  • DX (Directional Index): Quantifies trend strength for the current period, regardless of direction — this module's third output. A trader who wants the further-smoothed ADX (a simple moving average of DX over the window) can compute it downstream from this output.

DMI is often used in conjunction with other indicators (e.g., Average True Range (ATR), Moving Averages) to refine entries and exits. For a historical perspective, see Wilder's original work.


Mathematical Formulation

The DMI calculation involves several steps, each smoothing price movements to filter out noise. Below are the key formulas:

1. True Range (TR)

True Range is the widest of the bar's own range and the gap from the previous bar's Close:

TRt=max⁡(Hight−Lowt, ∣Hight−Closet−1∣, ∣Lowt−Closet−1∣)\text{TR}_t = \max(\text{High}_t - \text{Low}_t,\ |\text{High}_t - \text{Close}_{t-1}|,\ |\text{Low}_t - \text{Close}_{t-1}|)

When the previous bar's Close is missing (for example the first bar of the series, or a data gap), TR falls back to the bar's own High − Low range — a missing Close never invalidates a bar.

2. Directional Movements

+DMt=Hight−Hight−1+\text{DM}_t = \text{High}_t - \text{High}_{t-1} −DMt=Lowt−1−Lowt-\text{DM}_t = \text{Low}_{t-1} - \text{Low}_t

If +DMt>−DMt+\text{DM}_t > -\text{DM}_t and +DMt>0+\text{DM}_t > 0, use +DMt+\text{DM}_t; else 0. If −DMt>+DMt-\text{DM}_t > +\text{DM}_t and −DMt>0-\text{DM}_t > 0, use −DMt-\text{DM}_t; else 0.

3. Smoothed Values

Apply a smoothing (usually Wilder's 14-period):

Smoothed +DMt=Previous Smoothed +DM−(Previous Smoothed +DM/N)++DMt\text{Smoothed } +\text{DM}_t = \text{Previous Smoothed } +\text{DM} - (\text{Previous Smoothed } +\text{DM} / N) + +\text{DM}_t

(similar for −DM-\text{DM} and TR\text{TR})

4. Directional Indicators

+DIt=(Smoothed +DMtSmoothed TRt)×100+\text{DI}_t = \left(\frac{\text{Smoothed } +\text{DM}_t}{\text{Smoothed TR}_t}\right) \times 100 −DIt=(Smoothed −DMtSmoothed TRt)×100-\text{DI}_t = \left(\frac{\text{Smoothed } -\text{DM}_t}{\text{Smoothed TR}_t}\right) \times 100

5. Directional Index (DX) and ADX

DXt=∣+DIt−−DIt+DIt+−DIt∣×100\text{DX}_t = \left|\frac{+\text{DI}_t - -\text{DI}_t}{+\text{DI}_t + -\text{DI}_t}\right| \times 100 ADXt=SMA of DX over N periods\text{ADX}_t = \text{SMA of DX over N periods}

Visualizing DMI

Calculation Flow

flowchart TD
    A[Price Data] --> B[Calculate TR, +DM, -DM]
    B --> C[Apply Smoothing]
    C --> D[Compute +DI, -DI]
    D --> E[Calculate DX]
    E --> F[Compute ADX]
    F --> G[DMI Output: +DI, -DI, ADX]

Signal Generation Workflow

sequenceDiagram
    participant Market
    participant DMI
    participant Trader
    Market->>DMI: New price data
    DMI->>DMI: Update +DI, -DI, ADX
    DMI->>Trader: Signal (+DI cross, -DI cross, ADX > 25)
    Trader->>Market: Execute trade or hold

Practical Use Cases

In Securities

  • Trend Confirmation: DMI helps confirm if a stock is in a strong uptrend or downtrend, filtering out sideways markets.
  • Entry/Exit Signals: Crossovers of +DI and -DI, especially when ADX is above a threshold (commonly 20 or 25), are used for entries and exits.
  • Volatility Regimes: ADX rising signals strengthening trends, while falling ADX warns of choppy/range-bound conditions.

In Cryptocurrencies

  • Volatility Adaptation: Crypto markets are highly volatile; DMI can help avoid false breakouts by requiring ADX confirmation.
  • Risk Management: During high ADX periods, traders may increase position size; during low ADX, reduce risk or avoid trading.

DMI in Macroeconomic Context

DMI is most powerful when combined with macro indicators such as CPI, VIX, and interest rates. For example, in a high-inflation, high-volatility regime, DMI can help filter out false breakouts and focus on robust trends.

flowchart TD
    A[Macro Data: CPI, VIX, Rates] --> B[Market Regime]
    B --> C{Trending?}
    C -->|Yes| D[Use DMI for Signal Confirmation]
    C -->|No| E[Reduce Risk, Avoid Trend Signals]

Example:

  • If CPI is rising and VIX is elevated, but DMI/ADX is low, avoid trend trades.
  • If CPI is stable, VIX is low, and ADX is rising, trend-following strategies using DMI are favored.

For more on macro integration, see Investopedia: Using Technicals with Macro.


Advantages and Limitations

Advantages:

  • Measures both trend direction and strength
  • Helps avoid whipsaws in sideways markets
  • Versatile across asset classes and timeframes

Limitations:

  • Lagging indicator (uses smoothed data)
  • Can generate false signals in choppy markets
  • Requires parameter tuning for different assets

References and Further Reading


Data Alignment in Systemic

DMI requires three aligned price series (High, Low, Close) from the same asset and timeframe.

Input Requirements

InputTypeAlignment Behavior
Price HighSeriesMust match length of Low and Close
Price LowSeriesMust match length of High and Close
Price CloseSeriesMust match length of High and Low
WindowConstantLookback period (no alignment needed)

Automatic Alignment

If your price inputs have different frequencies:

  • All inputs are upsampled to the finest resolution
  • Forward-fill is applied to maintain the last known value

Critical: All three price series should come from the same asset and timeframe. Mixing price data from different sources produces invalid DMI readings.


Missing Data

DMI needs High and Low together on every bar it uses — Price Close is read opportunistically for gap-aware True Range when available, and never required: a bar is never blanked by a missing Close (True Range simply falls back to that bar's High − Low range). The Window setting means N bars actually observed, not N calendar slots: on a market-closed gap (holiday, weekend, no data), the Wilder smoothing keeps counting back through real bars, bridging straight from the last session before the gap to the first session after it. Until the first window observed bars accumulate, +DI/-DI/DX have no value yet — this shows as a gap, never a misleading zero. A flat window (High and Low both constant, so up-moves and down-moves cancel) is the one case that legitimately produces +DI = -DI = 0.0 — DX itself is then an honest 0/0 and reports as a gap too.


Indicator Assessment

%%{init: {"themeVariables": {"cScale0": "#4F46E5", "cScale1": "#059669"}}}%%
quadrantChart
    title DMI Indicator Assessment
    x-axis Low --> High
    y-axis Low --> High
    quadrant-1 High Popularity & Reliability
    quadrant-2 High Reliability & Low Popularity
    quadrant-3 Low Reliability & Popularity
    quadrant-4 High Popularity & Low Reliability
    "Traditional Markets": [0.85, 0.80]
    "Cryptocurrency": [0.70, 0.65]
DimensionStocks/MacroCryptoExplanation
Popularity⭐⭐⭐⭐⭐⭐⭐⭐⭐DMI/ADX is one of the most widely used trend indicators in technical analysis, created by J. Welles Wilder who also created RSI. Standard in most trading platforms.
Reliability⭐⭐⭐⭐⭐⭐⭐Highly reliable for trend confirmation in trending markets. However, it's a lagging indicator and can generate false signals in choppy, ranging markets.
Complexity⭐⭐⭐⭐⭐⭐Multi-step calculation involving True Range, directional movements, and smoothing. Interpretation requires understanding of +DI/-DI crossovers and ADX thresholds.
Versatility⭐⭐⭐⭐⭐⭐⭐⭐Works across all timeframes and asset classes. Best for trend-following strategies; less effective in ranging markets. The three outputs (+DI, -DI, DMI) provide both direction and strength.
Recent Interest⭐⭐⭐⭐⭐⭐Steady interest as a foundational indicator. Often combined with other Wilder indicators (RSI, ATR) in systematic trading.

Glossary

  • +DI / -DI: Positive/Negative Directional Indicator
  • ADX: Average Directional Index
  • True Range (TR): Largest of current high-low, high-previous close, low-previous close
  • Smoothing: Averaging technique to reduce noise
  • Crossover: When one indicator line crosses another, often used as a signal
  • Volatility Regime: Market state defined by high or low volatility (see VIX)
  • Macro Indicator: Economic data such as CPI, interest rates, or employment

This documentation is for educational purposes and should not be considered investment advice. Always consult multiple sources and consider your risk tolerance before trading.

Rendering diagrams...
© 2026 WanoLabs. All rights reservedAlpha build v0.1.5