Bentrix Docs
HomePricingDashboard

Average Directional Index, Wilder's ADX Wilder

Trend strengthoscillator3 linesin every package

MT5's iADXWilder, kept as a separate kind from its plain iADX because it is a genuinely different computation and not a preference: Wilder smoothing throughout, with +DM and −DM smoothed separately from true range, and a seed that comes off a branch of MT5's own that the shipped example leaves dead.

It measures trend strength as ADX does. That seed matters: against TA-Lib's classic mean seed it can move the reading by tens of points out of 100 near the start, the gap fading with Wilder's long memory.

01The study, live

Live figureScroll to zoom, drag the bars to pan.
2025
bar —O — H — L — C —main line —signal —third line —first value at —
Show where:

Computed by Bentrix’s own code over the same synthetic bars on every page — an illustration of how the study behaves, not a market.

What this figure shows

The figure is computed over 300 sample bars. ADX Wilder has no value on the first 15 — the bars it needs before it can answer — and its first value stands on bar 16. Its line runs between 16.45 and 61.07 on these bars, and the last value is 31.34. The pane's scale is fixed at 0 to 100, the range the study can take. Counting the conditions the study declares on these bars: crosses above 20 once; crosses below 20 once; crosses above 25 3 times; crosses below 25 3 times; +DI crosses above −DI 4 times; +DI crosses below −DI 4 times. Press a condition under the figure to see each place marked. As states rather than moments: is above 20 on 251 bars; is below 20 on 21 bars; is above 25 on 230 bars; is below 25 on 42 bars; +DI is above −DI on 157 bars; +DI is below −DI on 128 bars.

02Its parts, named

The bars it readseach bar's open, high, low and closeWarm-upno value on the first 15 bars: thestudy needs them before it cananswerThe main linethe study's own value on each barThe second linedrawn with the main line: its signalor its partnerLevel 25a fixed reference the study is readagainstLevel 20a fixed reference the study is readagainstThe third linethe study's third value
Computed by Bentrix’s own code over the sample bars. It is drawn on once, as you reach the figure.

03What you see

ADX Wilder is three lines in a pane of their own, between 0 and 100: the ADX line, which measures how strong a trend is whatever its direction, and the two directional lines, +DI and −DI, which say which side has had the larger moves. It is the directional system as MetaTrader 5's ADX Wilder computes it, with Wilder's own smoothing at every step.

04Where it comes from

J. Welles Wilder introduced the Directional Movement System in his 1978 book. The ADX was his answer to a question his other studies could not answer: is there a trend at all?

05The formula

Directional movement per bar — each bar's rise above the previous high and fall below the previous low, only the larger kept:

+DM=max(Ht−Ht−1,0),−DM=max(Lt−1−Lt,0)

Each, and the true range, is averaged Wilder's way, started from zero on bar N:

x~t=(N−1)x~t−1+xtN
+DI=100·+DM~TR~,−DI=100·−DM~TR~,DX=100·|+DI−(−DI)|+DI+(−DI)
ADX Wildert=(N−1)ADX Wildert−1+DXtN
Ht, Ltthis bar's high and low; t−1, the bar before
+DM, −DMthe upward and downward directional movement of the bar
x~x averaged Wilder's way over N bars
TRthe bar's true range
+DI, −DIthe two directional lines, in per cent
Nthe period, in bars — 14 by default

As Bentrix computes it (MetaTrader 5's ADX Wilder): the two DI lines are drawn from bar N+1 and the main line from bar 2N.

06A worked example

The sample bars used here are eight: closes 20, 21, 23, 22, 24, 25, 24, 26; highs 21, 22, 24, 24, 25, 26, 26, 27; lows 18, 19, 20, 21, 21, 23, 23, 23; opens 19, 20, 21, 23, 22, 24, 25, 24.

Take a period of 3. From each bar to the next, the up-move is the rise of the high and the down-move the fall of the low; the larger of the two, if it is positive, is that bar's directional movement, and the other is zero.

For bars 2 to 4 the highs rose by 1, 2, 0 and the lows fell by -1, -1, -1 (a negative number is a rise). So +DM is 1, 2, 0 and −DM is 0, 0, 0; the true ranges are 3, 4, 3.

MetaTrader's ADX Wilder, which Bentrix computes here, keeps three smoothed averages — of +DM, of −DM and of the true range — that start at zero on bar 4 (the period plus one) and move a third of the way to each new figure. After bar 4 (0, 0 and 3) they read 0.00, 0.00 and 1.00. On bar 5 (1, 0 and 4): +DM = (2 × 0.00 + 1) / 3 = 0.33 and the true range = (2 × 1.00 + 4) / 3 = 2.00.

+DI = 100 × 0.33 / 2.00 = 16.67 and −DI = 100 × 0 / 2.00 = 0.00

On bar 6 (1, 0 and 3): +DM becomes 0.56, the true range 2.33, and +DI = 23.81.

DX = 100 × |16.67 − 0.00| / (16.67 + 0.00) = 100.00

All of the directional movement in this window was upward, so DX is at its ceiling. It says nothing about which way: the mirror image of these bars gives the same 100.

ADX Wilder smooths as Wilder's book does at every step — the averages above, then his average of DX — which is what distinguishes ADX Wilder from MetaTrader's plain ADX, built on exponential averages. Its average of DX starts at zero too: with every DX from bar 5 on at 100, the line climbs a third of the remaining way on each bar — 33.33, 55.56, then 70.37 on bar 7 and 80.25 on bar 8.

07Built in Assay

The same study written in Assay, Bentrix’s script language, and drawn by Bentrix itself as the script’s graph: each block is one step of the formula. On the ladder the steps stand in the script’s order, one a row; on the board each wire carries a value from the block that gives it to the block that reads it, left to right. The script computes exactly what the study computes — Bentrix checks the two against each other, candle by candle.

THE SCRIPT’S GRAPH
//@version=6
indicator("Average Directional Movement Index, Wilder")
length = input.int(14, "Length")
upMove = math.max(high - high[1], 0)
downMove = math.max(low[1] - low, 0)
// A bar's directional movement is the larger of its rise above the last high and its fall below the last low.
plusDM = upMove > downMove ? upMove : 0.0
minusDM = downMove > upMove ? downMove : 0.0
trueRange = math.max(math.abs(high - low), math.abs(high - close[1]), math.abs(low - close[1]))
// Wilder's averages, as MetaTrader's ADX Wilder starts them: from zero, on the bar `length`.
var float range = 0.0
var float plusAvg = 0.0
var float minusAvg = 0.0
var float adx = 0.0
float plusDI = 0.0
float minusDI = 0.0
if bar_index >= length
    range := (range * (length - 1) + trueRange) / length
    plusAvg := (plusAvg * (length - 1) + plusDM) / length
    minusAvg := (minusAvg * (length - 1) + minusDM) / length
    plusDI := range != 0 ? 100 * plusAvg / range : 0.0
    minusDI := range != 0 ? 100 * minusAvg / range : 0.0
// The gap between the two directional lines as a share of their sum, smoothed the same way.
dx = plusDI + minusDI != 0 ? 100 * math.abs((plusDI - minusDI) / (plusDI + minusDI)) : 0.0
if bar_index >= length - 1 and bar_index >= 1
    adx := (adx * (length - 1) + dx) / length
plot(bar_index >= 2 * length ? adx : na, "ADX")
plot(bar_index >= length + 1 ? plusDI : na, "+DI")
plot(bar_index >= length + 1 ? minusDI : na, "-DI")
hline(20)
hline(25)

Paste it into the Assay IDE to put it on a chart, or to change it. Looking at the graph is free in every package; editing it as blocks is Plus.

08Readings — what traders look for

The main line above 20–25 is read as a trending market; below 20 as a ranging one. A rising main line as the trend strengthening — in either direction.

+DI above −DI is read as upward movement having dominated recently; a cross of the two as the dominant direction changing.

The main line turning down from a high level is read as the trend's strength fading, not necessarily the trend ending.

How a rising ADX fails. A rising line says the gap between the two directional lines has been widening. It keeps rising for a while after the move has stopped, because it is a smoothing of a smoothing; the highest ADX readings usually come after the fastest part of a trend.

How the 20 and 25 levels fail. They are conventions from daily commodity charts. On another period or market the line may live entirely above or below them.

09In different markets and timeframes

ADX Wilder is the directional index smoothed as Wilder's book does at every step; it behaves as the ADX does, a little more smoothly, and is drawn with its two directional lines.

10With other studies

Read as the ADX is: the main line for strength, the two DI lines for direction. Beside MetaTrader's plain ADX it shows what the choice of smoothing changes.

11What it does not tell you

!

ADX Wilder's main line has no direction: a strong fall raises it as much as a strong rise. It is built from three layers of smoothing and turns late.

12Inputs and defaults

ADX Wilder (14, Chart)settings card
1Period14
2TimeframeChart
3Wait for the candle to closeOn
  1. 1
    Period — 14The window of Wilder's smoothing. Longer: a steadier line that reacts late. Shorter: quick and erratic. Wilder's own figure is 14.
  2. 2
    Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
  3. 3
    Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.

The settings in use

  • In use14, as for the ADX.

13Limits and common misreadings

ADX Wilder is MetaTrader 5's computation with Wilder's own smoothing at every step. The plain ADX is smoothed differently under each of its two conventions, so the values of the two studies differ, most at the start; the ADX's own page describes those conventions.

14Conditions an alert or a strategy can watch

crosses above 20 eventcrosses below 20 eventis above 20 stateis below 20 statecrosses above 25 eventcrosses below 25 eventis above 25 stateis below 25 state+DI crosses above −DI event+DI crosses below −DI event+DI is above −DI state+DI is below −DI state

Event: the bar it happens on an event happens on one barState: every bar while it holds a state holds on every bar while it lasts

These are the conditions the study itself declares — the same rules the alert editor and the strategy engine read, and the ones the figure's chips show.

15Practise it in the laboratory

Put ADX and ADX Wilder with the same period in two panes under MetaTrader's convention and compare: the Wilder line is the smoother of the two.

Open the laboratory

17In Bentrix

  • From the menu: a chart's Indicators button › Trend strength › ADX Wilder, or type ADX Wilder in its search.
  • Its settings: the settings card opens when it is added; its legend's name opens it again.

18From an agent or a program

Two tools reach it. study_values computes it over a workbench’s candles up to the clock — no chart needed — and study_attach puts it on a chart, where it is drawn and saved with the chart ({"chart": "<chart uri>", "kind": "adxw"}).

The study, as a chart files it

This is a new ADX Wilder’s entry — its kind, its calculation, the price it reads and its settings. Change a setting here to read it with other inputs.

{
  "applied": "close",
  "convention": "mt5",
  "kind": "adxw",
  "settings": {
    "period": 14,
    "shape": "period"
  }
}

An agent

An agent calls the MCP tool with it:

{
  "name": "study_values",
  "arguments": {
    "bench": "bentrix://lab/\u2026/bench/\u2026",
    "symbol": "EURUSD",
    "timeframe": "H1",
    "limit": 5,
    "study": {
      "applied": "close",
      "convention": "mt5",
      "kind": "adxw",
      "settings": {
        "period": 14,
        "shape": "period"
      }
    }
  }
}

A program

A program does the same in its language — bench and market as in the built-in indicators guide:

Python

values = client.study.values(bench, market, "H1", {"applied": "close", "convention": "mt5", "kind": "adxw", "settings": {"period": 14, "shape": "period"}}, limit=5)
print("times:", values["times"])
for line in values["lines"]:
    print("line:", line["line"])
    print("  newest values:", line["values"])

JSJavaScript

const values = await client.study.values({ bench, symbol: market, timeframe: "H1", study: { "applied": "close", "convention": "mt5", "kind": "adxw", "settings": { "period": 14, "shape": "period" } }, limit: 5 });
console.log("times:", values.times);
for (const line of values.lines) {
  console.log("line:", line.line);
  console.log("  newest values:", line.values);
}

C#C#

var values = await client.Study.Values(bench, market, "H1", new Dictionary<string, object?> { ["applied"] = "close", ["convention"] = "mt5", ["kind"] = "adxw", ["settings"] = new Dictionary<string, object?> { ["period"] = 14, ["shape"] = "period" } }, limit: 5);
Console.WriteLine($"times: {values!["times"]!}");
foreach (var line in values!["lines"]!.AsArray())
{
    Console.WriteLine($"line: {line!["line"]!}");
    Console.WriteLine($"  newest values: {line!["values"]!}");
}

GOGo

values := must(client.Study.Values(ctx, mcp.StudyValuesArgs{Bench: bench, Symbol: market, Timeframe: "H1", Study: map[string]any{"applied": "close", "convention": "mt5", "kind": "adxw", "settings": map[string]any{"period": 14, "shape": "period"}}, Limit: mcp.Ptr[int64](5)}))
fmt.Println("times:", at(values, "times"))
for _, line := range at(values, "lines").([]any) {
	fmt.Println("line:", at(line, "line"))
	fmt.Println("  newest values:", at(line, "values"))
}

Java

Object values = client.study.values(new Bentrix.StudyApi.ValuesArgs(bench, market, "H1", obj("applied", "close", "convention", "mt5", "kind", "adxw", "settings", obj("period", 14, "shape", "period"))).limit(5L));
System.out.println("times:" + " " + at(values, "times"));
for (Object line : (List<Object>) at(values, "lines")) {
    System.out.println("line:" + " " + at(line, "line"));
    System.out.println("  newest values:" + " " + at(line, "values"));
}

C++C++

auto values = client.study.values_(StudyApi::ValuesArgs(bench, market, "H1", Json::Object{{"applied", "close"}, {"convention", "mt5"}, {"kind", "adxw"}, {"settings", Json::Object{{"period", 14}, {"shape", "period"}}}}).limit(5));
std::cout << "times:" << " " << values["times"].dump() << std::endl;
for (const Json &line : values["lines"].arr()) {
    std::cout << "line:" << " " << line["line"].dump() << std::endl;
    std::cout << "  newest values:" << " " << line["values"].dump() << std::endl;
}

Julia

values = client.study.values(bench, market, "H1", Dict{String,Any}("applied" => "close", "convention" => "mt5", "kind" => "adxw", "settings" => Dict{String,Any}("period" => 14, "shape" => "period")); limit = 5)
println("times:", " ", values["times"])
for line in values["lines"]
    println("line:", " ", line["line"])
    println("  newest values:", " ", line["values"])
end

RR

values <- client$study$values(bench, market, "H1", list(applied = "close", convention = "mt5", kind = "adxw", settings = list(period = 14, shape = "period")), limit = 5)
cat("times:", format(values$times), "\n")
for (line in values$lines) {
  cat("line:", format(line$line), "\n")
  cat("  newest values:", format(line$values), "\n")
}

RRust

let values = client.study().values(mcp::StudyValuesArgs::new(bench.clone(), market.clone(), "H1", serde_json::json!({"applied": "close", "convention": "mt5", "kind": "adxw", "settings": {"period": 14, "shape": "period"}})).limit(5))?;
println!("times: {}", values["times"]);
for line in values["lines"].as_array().into_iter().flatten() {
    println!("line: {}", line["line"]);
    println!("  newest values: {}", line["values"]);
}

Reading the answer

  • times — the candles’ open times, in milliseconds since 1970 (UTC), oldest first.
  • lines — one entry per line, in this order, each with its line name and its values; values[i] belongs to the candle at times[i].
  • The last value is the candle at the clock’s, which may still be forming: it changes until that candle closes, as on the chart. Nothing after the clock is ever computed.
  • null is a candle with no value yet — the warm-up, about 1 × the period at the start of the history.
  • Its fixed levels, drawn on the chart: [20.0, 25.0].
lineWhat it is
Mainthe indicator's own value
PlusDithe directional movement up (+DI)
MinusDithe directional movement down (−DI)

In a strategy

Filed under a key of your choice in a strategy document’s studies — here adxw: {"adxw": {"applied": "close", "convention": "mt5", "kind": "adxw", "settings": {"period": 14, "shape": "period"}}} — its rules can name:

WriteWhat it is
adxwits main line, as a value in a compare
adxw.plus_dithis line, as a value in a compare
adxw.minus_dithis line, as a value in a compare
{"cond": "adxw:level.cross_up:20"}a condition it declares itself
{"cond": "adxw:level.cross_down:20"}a condition it declares itself
{"cond": "adxw:level.above:20"}a condition it declares itself
{"cond": "adxw:level.below:20"}a condition it declares itself
{"cond": "adxw:level.cross_up:25"}a condition it declares itself
{"cond": "adxw:level.cross_down:25"}a condition it declares itself
{"cond": "adxw:level.above:25"}a condition it declares itself
{"cond": "adxw:level.below:25"}a condition it declares itself
{"cond": "adxw:di.cross_up"}a condition it declares itself
{"cond": "adxw:di.cross_down"}a condition it declares itself
{"cond": "adxw:di.above"}a condition it declares itself
{"cond": "adxw:di.below"}a condition it declares itself

19Sources

  1. Wilder, J. Welles Jr. New Concepts in Technical Trading Systems. Trend Research, 1978.

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed