Bentrix Docs
HomePricingDashboard

Plus Directional Indicator Plus DI

Trend strengthoscillatorone linein every package

+DI — the Wilder-smoothed up-move as a share of true range, so it is directional movement normalised by volatility.

It measures how much of recent range was made by upward extension. The conventional reading is +DI against −DI: which is higher, and the bar on which they cross.

01The study, live

Live figureScroll to zoom, drag the bars to pan.
bar —O — H — L — C —main 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. Plus DI has no value on the first 14 — the bars it needs before it can answer — and its first value stands on bar 15. Its line runs between 5.13 and 44.46 on these bars, and the last value is 23.05. 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: turns up 51 times; turns down 51 times. Press a condition under the figure to see each place marked. As states rather than moments: is rising on 89 bars; is falling on 196 bars.

02Its parts, named

The bars it readseach bar's open, high, low and closeWarm-upno value on the first 14 bars: thestudy needs them before it cananswerThe main linethe study's own value on each bar
Computed by Bentrix’s own code over the sample bars. It is drawn on once, as you reach the figure.

03What you see

+DI is one line in a pane of its own, between 0 and 100. It says how much of the recent true range was upward movement — highs reaching above the previous bar's high. It is one of the two directional lines of Wilder's system, drawn here by itself.

04Where it comes from

J. Welles Wilder introduced it in New Concepts in Technical Trading Systems (1978) as one layer of his Directional Movement System — the same book that gave the RSI, the ATR and the Parabolic SAR. +DI is the share of recent true range that was upward directional movement.

05The formula

Directional movement per bar — the bar's rise above the previous high and its fall below the previous low:

upt=Ht−Ht−1,downt=Lt−1−Lt

Only the larger of the two counts, and only if it is positive. A bar whose rise is the larger has that rise as its +DM; on every other bar — the fall was larger, or neither was positive — its +DM is zero.

The +DM of each bar and the bar's true range are each summed Wilder's way over N bars, and +DI is the first as a percentage of the second:

+DIt=100·+DM~tTR~t
Ht, Ltthis bar's high and low; t−1, the bar before
upt, downtthe bar's rise above the previous high and its fall below the previous low
+DM~, TR~the upward movement and the true range, each smoothed Wilder's way over N bars

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.

Wilder's running totals begin as the sums over the first two of those bars (the period less one): +DM = 1 + 2 = 3, −DM = 0, true range = 3 + 4 = 7. From the next bar on, each total drops a third of itself and adds the new bar's figure. On bar 4 (0, 0 and 3): +DM = 3 − 1 + 0 = 2.00 and the true range = 7 − 2.33 + 3 = 7.67.

+DI = 100 × 2.00 / 7.67 = 26.09 and −DI = 100 × 0 / 7.67 = 0.00

On bar 5 the totals again drop a third and add the new bar (1, 0 and 4): +DM becomes 2.33, the true range 9.11, and +DI = 25.61.

+DI is the share of the window's true range that was upward directional movement, as a percentage. The two lines do not add up to 100: a bar that moves inside the previous bar's range adds to the true range and to neither line.

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("Plus Directional Indicator")
length = input.int(14, "Length")
upMove = high - high[1]
downMove = low[1] - low
// 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 and upMove > 0 ? upMove : 0.0
minusDM = downMove > upMove and downMove > 0 ? downMove : 0.0
trueRange = math.max(high - low, math.abs(high - close[1]), math.abs(low - close[1]))
// Wilder's running sums: the first is a plain sum, then each bar drops one part in `length` and adds the new bar.
var float plusSum = 0.0
var float minusSum = 0.0
var float rangeSum = 0.0
if bar_index > 0 and bar_index < length
    plusSum += plusDM
    minusSum += minusDM
    rangeSum += trueRange
else if bar_index >= length
    plusSum := plusSum - plusSum / length + plusDM
    minusSum := minusSum - minusSum / length + minusDM
    rangeSum := rangeSum - rangeSum / length + trueRange
// The smoothed upward movement as a share of the smoothed true range.
plusDI = bar_index >= length ? 100 * (plusSum / rangeSum) : na
plot(plusDI, "+DI")

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

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

How a crossing with −DI fails. Wilder read the crossing of the two lines as a change of direction, and added his own condition — the extreme point rule, waiting for price to pass the extreme of the crossing bar — because the lines cross repeatedly in a market without direction.

How the level fails. A high reading says most of the recent range was movement one way. After a single wide bar the line stays high for a period with nothing further happening.

09In different markets and timeframes

+DI is one half of a pair and is read against the other. In a trend one line stays above the other for long stretches; in a range the two cross repeatedly, which is why Wilder added his extreme-point rule to their crossings.

10With other studies

Read with −DI (the pair is the reading) and with the ADX, which says whether their separation amounts to a trend. The Vortex Indicator is a later study of the same idea.

11What it does not tell you

!

+DI says how much of the recent range was upward movement beyond the previous bar. It does not say that price rose or fell overall — inside bars and gaps count differently from what a close-to-close change would show — and without −DI beside it there is nothing to compare it with.

12Inputs and defaults

Plus DI (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; shorter periods make the two lines cross more often.

13Limits and common misreadings

Two smoothings deep. The directional movement and the true range are each smoothed before they are divided, so the line trails the bars that moved it.

Read as a pair. Wilder's readings are of +DI against −DI; a level of one line alone has no agreed meaning.

14Conditions an alert or a strategy can watch

turns up eventturns down eventis rising stateis falling 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 +DI and −DI in one pane with ADX hidden. Replay a range and count their crossings; then replay a trend and count again.

Open the laboratory

17In Bentrix

  • From the menu: a chart's Indicators button › Trend strength › Plus DI, or type Plus DI 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": "plus_di"}).

The study, as a chart files it

This is a new Plus DI’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": "talib",
  "kind": "plus_di",
  "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": "talib",
      "kind": "plus_di",
      "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": "talib", "kind": "plus_di", "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": "talib", "kind": "plus_di", "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"] = "talib", ["kind"] = "plus_di", ["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": "talib", "kind": "plus_di", "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", "talib", "kind", "plus_di", "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", "talib"}, {"kind", "plus_di"}, {"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" => "talib", "kind" => "plus_di", "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 = "talib", kind = "plus_di", 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": "talib", "kind": "plus_di", "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.
lineWhat it is
Mainthe indicator's own value

In a strategy

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

WriteWhat it is
plus_diits main line, as a value in a compare
{"cond": "plus_di:line.turns_up"}a condition it declares itself
{"cond": "plus_di:line.turns_down"}a condition it declares itself
{"cond": "plus_di:line.rising"}a condition it declares itself
{"cond": "plus_di:line.falling"}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