Directional Movement Index (DMI)

Calculate Wilder’s Directional Movement System: the smoothed Plus and Minus Directional Movement (+DM, -DM), the Directional Indicators (+DI, -DI) and the Directional Movement Index (DX).

The Directional Movement is the part of a period’s range outside the previous period’s range: upward when the high rises above the previous high by more than the low falls below the previous low, downward the other way around. Wilder sums each over the window with his smoothing and divides it by the smoothed True Range, which gives the Directional Indicators: the share of the recent range that moved up (+DI) and down (-DI). The DX is their difference as a share of their sum, high in a trend in either direction and low in a range; its Wilder average is the ADX.

The formula is as follows:

\[+ \operatorname{DM}(1) = \text{High} - \text{Previous High},\;\; \text{where positive and larger than Previous Low} \;\mathord{-} \;\text{Low},\;\; \text{else 0}\] \[\operatorname{DM}(1) = \text{Previous Low} - \text{Low},\;\; \text{where positive and larger than High} \;\mathord{-} \;\text{Previous High},\;\; \text{else 0}\] \[+ \text{DM} = \text{Wilder's sum of} + \operatorname{DM}(1) \;\text{over window},\;\; \operatorname{Sum}(t) = \operatorname{Sum}(t-1) - \frac{\operatorname{Sum}(t-1)}{\text{window}} + + \operatorname{DM}(1) (t),\;\; \text{and -DM analogously}\] \[\text{+DI} = 100 \cdot + \frac{\text{DM}}{\text{Wilder's sum of the True Range}},\;\; \text{-DI} = 100 \cdot - \frac{\text{DM}}{\text{Wilder's sum of the True Range}}\] \[\text{DX} = \frac{100 \cdot \left|\text{+DI} - \text{-DI}\right|}{\text{+DI} + \text{-DI}}\]

+DI crossing above -DI is Wilder’s buy signal and crossing below it his sell signal, which he only took when the ADX showed a trend. The DX itself is jumpy; the ADX (get_average_directional_index) and the ADXR (the rating of get_average_directional_index) smooth it.

Also known as: DMI, Directional Movement System, +DM, -DM, +DI, -DI, DX, PLUS_DM, MINUS_DM, PLUS_DI, MINUS_DI, directional indicators.

Example · AAPL · 2021 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_directional_movement_index:

from financetoolkit import Toolkit

toolkit = Toolkit(
    tickers=["AAPL"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.technicals.get_directional_movement_index().xs("AAPL", level=1, axis="columns")

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

How did the directional movement of Apple (+DI, -DI and DX) develop in 2025?

Which returns:

Parameters

get_directional_movement_index accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe time period to consider for historical data. Options are: “intraday” (intraday prices), “daily” (daily prices), “weekly” (weekly prices), “monthly” (monthly prices), “quarterly” (quarterly prices), “yearly” (yearly prices). Defaults to “daily”."weekly"
close_columnstrThe column name for closing prices in the historical data. Defaults to “Adj Close”, in which case the open, high and low prices are adjusted for dividends in the same way."Close"
windowintThe number of periods of Wilder’s smoothing. Defaults to 14.20
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise).2
growthboolWhether to calculate the growth of the indicator values. Defaults to False.True
lagint | list[int]The lag to use for the growth calculation. Defaults to 1.4
standardizeboolWhether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False.True
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper Wilder, J.W. Jr. (1978). “New Concepts in Technical Trading Systems.” Trend Research.
  • Library Referenced against TA-Lib’s PLUS_DM
  • Library Referenced against TA-Lib’s MINUS_DM
  • Library Referenced against TA-Lib’s PLUS_DI
  • Library Referenced against TA-Lib’s MINUS_DI
  • Library Referenced against TA-Lib’s DX
Share