Bentrix Docs
HomePricingDashboard

Plus Directional Movement Plus DM

Trend strengthoscillatorone linein every package

+DM — the Wilder-summed up-move, before it is divided by true range.

It measures upward range extension in price units, so unlike +DI it is not comparable across instruments or volatility regimes. It is shown as the raw input the DI lines are built from.

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 DM has no value on the first 13 — the bars it needs before it can answer — and its first value stands on bar 14. Its line runs between 0.00068 and 0.0079 on these bars, and the last value is 0.0033. Counting the conditions the study declares on these bars: turns up 54 times; turns down 55 times. Press a condition under the figure to see each place marked. As states rather than moments: is rising on 84 bars; is falling on 202 bars.

02Its parts, named

The bars it readseach bar's open, high, low and closeWarm-upno value on the first 13 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

+DM is one line in a pane of its own, at or above zero, in price units. It is the smoothed amount by which highs have reached above the previous bar's high — the upward directional movement of Wilder's system, before it is divided by the true range to give +DI.

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. +DM is its first quantity: each bar's rise of the high above the previous high, kept only when it is the larger of the two movements, and smoothed.

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.

+DM, the study, is that per-bar figure summed Wilder's way over N bars:

+DMt=+DMt−1−+DMt−1N+up-movet
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
up-movetthe bar's rise, where it is the larger of the two and positive; else 0
Nthe period, in bars

It is a running total, not an average: about N times the per-bar figure, in price units.

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.

The line drawn here is Wilder's running total of +DM itself. It begins as the sum over the first two of those bars (the period less one): 1 + 2 = 3.00 on the third bar. On each later bar the total drops a third of itself and adds the new bar's +DM: on the fourth bar 3.00 − 1.00 + 0 = 2.00, and on the fifth, whose +DM is 1, 2.00 − 0.67 + 1 = 2.33.

It is in price units, not a percentage; dividing it by the true range's total is what turns it into +DI.

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 Movement")
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
plot(bar_index >= length - 1 ? plusSum : na, "+DM")

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

How its size fails. The line is the smoothed rise of the high beyond the previous bar, in price units. It grows with volatility as much as with direction: a wild, directionless market gives large values of both DM lines at once, and only their ratio to the true range (the DI lines) separates the two.

09In different markets and timeframes

+DM is the first quantity of the directional system, in price units: it grows with volatility as well as with direction, so its level means little on its own and nothing across markets.

10With other studies

Read beside +DI, which divides it by the true range, to see what that normalising removes.

11What it does not tell you

!

It is a smoothed amount of price movement in one direction, in price units. It does not say how large that movement was against the bars' whole range — that comparison is +DI — and a rising value can mean a trend or simply larger bars.

12Inputs and defaults

Plus DM (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; TA-Lib's value is a smoothed running total over the period, about N times the per-bar figure.

13Limits and common misreadings

In price units. Its size follows the instrument's price and volatility and cannot be compared between markets.

Wilder's running sum, not an average. With TA-Lib's convention the value is a smoothed total over the period, about N times the per-bar figure.

An outside bar counts once. When a bar exceeds the previous bar on both sides only the larger excess is kept; the other is discarded.

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 +DM and +DI with the same period in two panes; find a stretch where volatility rose and note that DM rose with it while DI did not.

Open the laboratory

17In Bentrix

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

The study, as a chart files it

This is a new Plus DM’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_dm",
  "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_dm",
      "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_dm", "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_dm", "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_dm", ["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_dm", "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_dm", "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_dm"}, {"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_dm", "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_dm", 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_dm", "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_dm: {"plus_dm": {"applied": "close", "convention": "talib", "kind": "plus_dm", "settings": {"period": 14, "shape": "period"}}} — its rules can name:

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