Skip to content
All library documents

Computing DMI, ADX, and ADXR from Directional Indicators

Article Strategy library · Author: 发明者量化-小小梦

Summary

This example shows how to derive directional movement indicators from high, low, and close records. It obtains positive and negative directional indicators with a technical analysis library, then computes DX as the absolute difference between the two indicators divided by their sum, expressed as a percentage. A simple moving average of DX produces the example’s ADX series. ADXR is then formed by averaging an ADX value with one from a specified number of periods earlier. The routine plots the indicators using the penultimate record and refreshes on a repeating loop.

The example is a calculation and visualization demonstration, not a trading strategy: it gives no entry rules, portfolio sizing, or performance analysis. Its backtest settings describe an hourly BTC/USDT sample, but no results are supplied. The implementation skips missing or zero indicator values when constructing DX, which can affect series alignment with the original bars and deserves careful validation. The ADX calculation uses a simple moving average as written, so users should confirm that this matches their intended indicator convention before relying on the output.

Key ideas

  • Positive and negative directional indicators are calculated from price high, low, and close data.
  • DX measures the normalized difference between the positive and negative indicators.
  • The example smooths DX with a simple moving average to form ADX.
  • ADXR averages the current ADX with an earlier value separated by a configured period.
  • Skipping missing values may alter alignment, so the output should be checked against bar timestamps.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.