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
ta.dmi(diLength, adxSmoothing) → [series float, series float, series float]Arguments
| Parameter | Type | Description |
|---|---|---|
| diLength | simple int | DI period. |
| adxSmoothing | simple int | ADX 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
//@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
Frequently Asked Questions
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.
Related Pine Script Functions
ta.macd() - MACD
Learn how to use ta.macd() in Pine Script. Syntax, parameters, code examples for MACD line, signal line, and histogram.
ta.supertrend() - Supertrend
Learn how to use ta.supertrend() in Pine Script. Syntax, parameters, code examples for the ATR-based trend overlay.
ta.sar() - Parabolic SAR
Learn how to use ta.sar() in Pine Script. Syntax, parameters, code examples for the Parabolic Stop and Reverse indicator.
ta.rsi() - Relative Strength Index
Learn how to use ta.rsi() in Pine Script. Syntax, parameters, code examples for the RSI momentum oscillator.
ta.atr() - Average True Range
Learn how to use ta.atr() in Pine Script. Syntax, parameters, code examples for the Average True Range volatility indicator.