TrendPine Script v6

ta.dmi()Directional Movement Index

ta.dmi() calculates the Directional Movement Index and returns three series in this order: +DI, -DI, and ADX. Both length arguments are simple integers.

Pine Script v6 reference verified: · TradingView reference

Syntax

Syntax
ta.dmi(diLength, adxSmoothing) → [series float, series float, series float]

Arguments

ParameterTypeDescription
diLengthsimple intDI period.
adxSmoothingsimple intADX smoothing period.

Returns

Tuple of three DMI series: Positive Directional Movement (+DI), Negative Directional Movement (-DI) and Average Directional Movement Index (ADX).

Remarks

The result is a tuple, not an array. Destructure it into three series before applying history references or using an individual result elsewhere.

Code Examples

Pine Script v6 Example
//@version=6
indicator(title="Directional Movement Index", shorttitle="DMI", format=format.price, precision=4)
len = input.int(17, minval=1, title="DI Length")
lensig = input.int(14, title="ADX Smoothing", minval=1)
[diplus, diminus, adx] = ta.dmi(len, lensig)
plot(adx, color=color.red, title="ADX")
plot(diplus, color=color.blue, title="+DI")
plot(diminus, color=color.orange, title="-DI")

Trading Applications

Measure trend strength with ADX

Identify trend direction with +DI/-DI crossovers

Filter trades based on ADX threshold

Combine with other indicators for trend confirmation

Related Functions

Frequently Asked Questions

ta.dmi() returns +DI, -DI, and ADX: components of the directional movement system used to gauge trend strength (ADX) and directional bias (+DI vs -DI).

Traders often treat rising ADX above roughly 20–25 as increasing trend strength, but thresholds are not fixed. Use ADX direction (rising/falling) and compare with your market and timeframe.

A common interpretation is bullish bias when +DI crosses above -DI and bearish when -DI crosses above +DI, often filtered by ADX to avoid weak-trend chop. Confirm with price structure and other tools.

No. Square brackets are Pine Script’s history-referencing operator, not tuple indexing. Destructure ta.dmi() into +DI, -DI, and ADX series first, then apply a history reference such as [1] to the individual series you need.

Yes. request.security() can evaluate a built-in function call or tuple and return the requested series. Destructure the returned tuple, and handle higher-timeframe offsets and lookahead deliberately to avoid repainting or future-data bias.

Generate ta.dmi() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.dmi() and other built-in functions instantly.