How Adx and Moving Average Are Calculated: Formulas, Inputs, and Checks

Learn ADX and moving average calculation steps and data needs.

What are Adx and Moving Average, and how do they relate?

ADX and a moving average are two separate technical indicators that are often used together.

  • Moving average (MA) is a smoothed line built from price data. It reduces noise by averaging past values. The most common version uses the closing price, but the method can be applied to any chosen price source (for example, open, high, low, or a mid-price), depending on the implementation.
  • ADX (Average Directional Index) is a measure of trend strength, not direction. It is built from directional movement and true range, then smoothed and averaged into an index.

The indicators do not “predict” outcomes by themselves. They reflect how past price movements behaved under specific calculation rules.

Moving average calculation (core mechanics)

Inputs and parameters

To calculate a moving average you need:

  • A price series: usually the close price for each time period.
  • A lookback length (often called period or window), denoted as N.
  • Optionally, a method for smoothing.

Simple Moving Average (SMA)

A common baseline is the Simple Moving Average over N periods.

Let (P_t) be the selected price at time (t). The SMA at time (t) is:

[ \text{SMA}t = \frac{1}{N}\sum{i=0}^{N-1} P_{t-i} ]

That means the MA at time (t) is the average of the last N price values, including (t).

Exponential Moving Average (EMA) (common alternative)

Many charting systems also offer EMA, which weights recent prices more. A typical EMA form uses a smoothing factor:

  • (\alpha = \frac{2}{N+1})

Then:

[ \text{EMA}t = \alpha P_t + (1-\alpha)\text{EMA}{t-1} ]

An EMA still uses N, but instead of taking a full average each time, it updates from the prior EMA value.

Practical calculation checks

To verify an MA calculation:

  • Confirm you used the same price source and same N.
  • Confirm indexing: MA values begin only after enough bars exist (SMA needs at least N data points; EMA still needs an initial value choice).
  • For EMA, confirm how the platform initializes the first EMA (different tools choose different starting points).

ADX calculation (core mechanics)

ADX uses several intermediate series. The most standard workflow uses directional movement (DM), true range (TR), smoothing, and then an averaged directional strength.

Step 1: Compute directional movement (+DM and -DM)

Let high, low, close prices for time (t) be (H_t), (L_t), and (C_t). Compute directional movement based on changes from (t-1) to (t):

  • Up move: (U_t = H_t - H_{t-1})
  • Down move: (D_t = L_{t-1} - L_t)

Then define:

[ +DM_t = \begin{cases} U_t, & \text{if } U_t > D_t \text{ and } U_t > 0 \ 0, & \text{otherwise} \end{cases} ]

[ -DM_t = \begin{cases} D_t, & \text{if } D_t > U_t \text{ and } D_t > 0 \ 0, & \text{otherwise} \end{cases} ]

Different implementations sometimes differ in edge-case handling, but the general idea is to assign positive movement only when the upward move dominates, and negative movement only when downward movement dominates.

Step 2: Compute true range (TR)

True range captures volatility relative to the previous close. A common definition is:

[ \text{TR}t = \max\Big( H_t - L_t,; |H_t - C{t-1}|,; |L_t - C_{t-1}| \Big) ]

Step 3: Smooth TR and DM values

ADX commonly uses a smoothing method over a lookback length, usually denoted N (often called the “period”). A classic approach is Wilder-style smoothing.

Let (\text{TRS}_t), (\text{+DMS}_t), and (-\text{DMS}_t) represent the smoothed values.

A common Wilder smoothing form is:

  • Initial smoothed value is often the sum of the first N raw values.
  • Then for (t > N):

[ \text{TRS}t = \text{TRS}{t-1} - \frac{\text{TRS}_{t-1}}{N} + \text{TR}_t ]

[ \text{+DMS}t = \text{+DMS}{t-1} - \frac{\text{+DMS}_{t-1}}{N} + \text{+DM}_t ]

[ \text{-DMS}t = \text{-DMS}{t-1} - \frac{\text{-DMS}_{t-1}}{N} + \text{-DM}_t ]

Because initialization varies by tool, verifying ADX often requires matching the exact smoothing and start-bar convention.

Step 4: Convert smoothed values into directional indicators

Compute directional strength measures:

[ +DI_t = 100\times \frac{\text{+DMS}_t}{\text{TRS}_t} ]

[ -DI_t = 100\times \frac{\text{-DMS}_t}{\text{TRS}_t} ]

Step 5: Compute DX and then ADX

Directional index:

[ \text{DX}_t = 100\times \frac{|(+DI_t) - (-DI_t)|}{(+DI_t) + (-DI_t)} ]

Then ADX averages DX values over a period, commonly the same N in many descriptions, producing:

[ \text{ADX}_t = \text{Average of DX over N periods (with a chosen smoothing method)} ]

Many implementations use Wilder smoothing for ADX after the initial average. The exact averaging/smoothing step is another place where calculator behavior can differ.

Evidence or example: recompute step-by-step with clear assumptions

Because formulas are algebraic, the most reliable “evidence” is a manual recomputation using a small window of historical OHLC data and the same parameter settings.

Here is a verification approach that does not assume any market outcome:

  1. Pick a fixed window length (N) for ADX and confirm (N) equals the “period” used by your chart tool.
  2. For a chosen time (t), compute (U_t) and (D_t) from (H_t, H_{t-1}, L_t, L_{t-1}).
  3. Compute (+DM_t) and (-DM_t) using the dominance and positivity rules.
  4. Compute (\text{TR}t) from (H_t, L_t, C{t-1}).
  5. Apply the same smoothing method your tool uses to obtain smoothed (\text{+DMS}_t), (-\text{DMS}_t), and (\text{TRS}_t).
  6. Compute (+DI_t), (-DI_t), then (\text{DX}_t), and finally the ADX value using the tool’s averaging/smoothing step.

For moving averages:

  • Use the same (N) and the same price source.
  • Recompute SMA by averaging the last N values, or EMA by applying (\alpha) and updating from the initial EMA.

If your computed series differs from the chart, the mismatch usually comes from one of these:

  • Different definitions of DM and TR edge cases.
  • Different smoothing method (Wilder vs EMA-like vs other).
  • Different initialization for the first smoothed value(s).
  • Different price source for the moving average.

Limitations and risks: where calculations can mislead or fail

Indicator mechanics do not guarantee interpretation

ADX is designed to express trend strength under its formula, but its scale and meaning depend on context. A high or rising ADX does not automatically imply a direction that will persist.

Similarly, a moving average smooths noise but can lag behind price. The “distance” between price and MA (if you choose to analyze it) is still derived from past data.

Trading foreign exchange and CFDs involves substantial risk. Information on FoxiForex is educational and is not personal financial advice. Sponsored placements are labelled clearly.