fintech-algorithms

Average Directional Index (ADX)

Smooth DX Without Inventing Direction

Install and import

bash
npm install fintech-algorithms
ts
import { adx } from "fintech-algorithms/technical-indicators/trend-systems/adx";

Signature

adx(high, low, close, period)

Average directional index: the smoothed magnitude of the gap between +DI and −DI. It measures whether a trend exists at all, and says nothing about its direction — which is why it is used as a filter rather than a signal.

Parameters

NameTypeNotes
highnumber[]Per-bar high prices, chronological.
lownumber[]Per-bar low prices, chronological.
closenumber[]Per-bar closing prices, chronological.
periodnumberWilder smoothing period, applied twice: once to the DI components and once to DX.
min: 1 · integer: true

Returns

Record<string, (number | null)[]> · length same-as-input

Parallel series: plus_di, minus_di, dx and adx.

Warm-up

The first 2 × period − 1 positions are null. ADX is a smoothing of DX, which is itself computed from smoothed components.

Errors

  • When period < 1 or is not an integer — throws RangeError
  • When the input series are not all the same length — throws RangeError

Complexity: time O(n), space O(n).

Worked example

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input

high
[109.485, 110.139028, 110.859574, 111.590939, 112.283113, 112.89901]

Showing 6 of 180 elements.

low
[107.2615, 107.406037, 107.92024, 108.58088, 109.35613, 110.189018]

Showing 6 of 180 elements.

close
[108.42, 108.957755, 109.593932, 110.295981, 111.021937, 111.725443]

Showing 6 of 180 elements.

period
14

Call

adx(high, low, close, period)

Returns

object with 4 fields: plus_di, minus_di, dx, adx

{
  "plus_di": [null, null, null, null, null, null],
  "minus_di": [null, null, null, null, null, null],
  "dx": [null, null, null, null, null, null],
  "adx": [null, null, null, null, null, null]
}

Diagrams

Average Directional Index (ADX) — canonical trace
Average Directional Index (ADX) — failure boundary
Average Directional Index (ADX) — mechanism map

Calculation flow

ADX calculation flow
flowchart LR
    A["Validated finalized bar"] --> B["Causal window or recursive state"]
    B --> C["Explicit seed and boundary rule"]
    C --> D["Aligned ADX output"]
    D --> E["Diagnostics and audit evidence"]

How it works

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References