Sidechair

ta.dmi()

Browse the reference

Returns the directional movement system as three series: +DI, -DI and ADX, computed from the chart's highs, lows and closes.

Try it in the editor

ta.dmi measures how much of each bar's range extends beyond the previous bar's range, upward and downward. Those directional moves and the true range are smoothed with ta.rma over diLength to give the +DI and -DI lines in percent.

ADX smooths |+DI - -DI| / (+DI + -DI) over adxSmoothing bars and scales it to percent. +DI and -DI first appear on bar number diLength + 1, ADX on bar number diLength + adxSmoothing.

Syntax

Pine Script
ta.dmi(diLength: simple int, adxSmoothing: simple int) -> [series float, series float, series float]

Arguments

NameTypeDefaultDescription
diLengthsimple intrequiredSmoothing length of the directional indicators. A whole number of 1 or more.
adxSmoothingsimple intrequiredSmoothing length of the ADX line. A whole number of 1 or more.

Returns

[series float, series float, series float]: +DI, -DI and ADX, each in percent.

Remarks

  • ADX measures trend strength regardless of direction. Values above about 25 are usually read as a trending market.
  • The two lines cross when the balance between upward and downward movement flips.

Example

Pine ScriptDirectional movement indexOpen in editor
//@version=6
indicator("DMI")
[plusDI, minusDI, adx] = ta.dmi(14, 14)
plot(plusDI, "+DI", color = color.green)
plot(minusDI, "-DI", color = color.red)
plot(adx, "ADX", color = color.blue, linewidth = 2)

See also

Runs on Sidechair