Skip to content
All library documents

Calculating Wilder’s ADX with a Ring Buffer in MQL5

Article MQL5 code base

Summary

This document describes an MQL5 class for calculating Wilder’s Average Directional Movement Index with a ring buffer. It explains the initialization settings, including the smoothing period and method, buffer capacity, and input indexing mode. The class accepts arrays of high, low, and close prices for batch calculation, or individual price values for element-by-element calculation. It also exposes the ADX, positive directional index, and negative directional index series, along with accessors for settings and required history.

The examples show how to integrate the class into an indicator’s calculation routine and copy values from its buffers, whose indexing follows time-series order. A second example demonstrates calculating from individual values and deriving additional lines from the stored results. The document is API and integration guidance, not a trading strategy: it provides no signal rules or performance tests. Users need the accompanying ring-buffer and moving-average classes, and should verify the indicator’s behavior in their own environment.

Key ideas

  • The class calculates Wilder’s ADX and exposes the positive and negative directional index lines.
  • It supports both array-based and individual-value calculations.
  • A ring buffer stores recent indicator values and uses time-series-compatible indexing.
  • The examples show integration with MQL5 indicator buffers, but provide no evidence of trading performance.

Tags

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