Average Directional Index (ADX)

Indicator that calculates the strength of tendencies, whether they are bullish or bearish.

Average Directional Index (ADX) calculates the strength of tendencies, whether they are bullish or bearish. Calculations are based on Moving Average of price range expansion over a set time, the default usually being 14 bars. It is used alongside a Negative Directional Indicator (-DI) and a Positive Directional Indicator (+DI).

Trading application

Price is the most important signal on the chart – first read that, and then check ADX in context of what the price is doing. ADX is shown as values between 0 and 100. When this value is under 20, the trend is considered weak, usually a sign of accumulation or distribution. When it’s over 40, ADX suggests the trend has directional strength. The indicator is usually plotted in the same window as the two Directional Movement Indicator (DMI) lines, from which ADX is derived. A common misunderstanding is that when the ADX line is falling, it means the trend is weakening, which is not usually the case. It’s better to interpret a falling ADX as ‘less strong’.

Calculation

Calculate the True Range (TR), Plus Directional Movement (+DM) and Minus Directional Movement (-DM) for each period.

Smooth these periodic values using Wilder's smoothing techniques:

Divide the n-day smoothed Plus Directional Movement (+DM) by the n-day smoothed True Range to find the n-day Plus Directional Indicator (+DIn). Multiply by 100 to move the decimal point two places. This +DI14 is the green Plus Directional Indicator line (+DI) that is plotted along with the ADX line.

Divide the n-day smoothed Minus Directional Movement (-DM) by the n-day smoothed True Range to find the n-day Minus Directional Indicator (-DIn). Multiply by 100 to move the decimal point two places. This -DIn is the red Minus Directional Indicator line (-DI) that is plotted along with the ADX line.

The Directional Movement Index (DX) equals the absolute value of +DIn less -DIn divided by the sum of +DIn and -DIn. Multiply the result by 100 to move the decimal point over two places.After all these steps, it is time to calculate the Average Directional Index (ADX) line. The first ADX value is simply n-day average of DX. Subsequent ADX values are smoothed by multiplying the previous n-day ADX value by n-1, adding the most recent DX value, and dividing this total by n.

Parameters

Input Parameters

Name

Type

Range of value

Description

period

int

<1, int.MaxValue>

Number of bars used for calculation.

Output Parameters

Indicator ouptuts a single value.

Type

Range of value

double

(0, double.MaxValue)

Examples

// Prints the current value of a 20 period ADX using
// the daily bars close price value.
adx = indicators.ADX(20).OnSeries(dailyBars);
Log("The current ADX value is " + adx.Value.ToString());
// Prints the previous value of a 20 period ADX.
adx = indicators.ADX(20).Keep(2).OnSeries(dailyBars);
Log("The current ADX value is " + adx.Values[0].ToString());

Complete example

using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.ADX;
public class MyStrategy : SingleMarketStrategy
{
private Bars dailyBars;
private ADX adx;
public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
{
dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(25);
adx = indicators.ADX(20).Keep(2).OnSeries(dailyBars);
}
public override void RegisterActions()
{
OnUpdateOf(dailyBars).Do(() =>
{
// Prints the current ADX value
Log("The current ADX value is " + adx.Value.ToString());
// Prints the previous ADX value
Log("The previous ADX value is " + adx.Values[1].ToString());
});
}
}