Skip to main content
On this page

ADX in Pine Script: DMI Values and Trend-Strength Filters

· 3 min read
Pineify Team
Pine Script and AI trading workflow research team

ADX measures directional movement strength without assigning an up or down direction. In Pine Script, ta.dmi() returns +DI, -DI and ADX together; a high ADX is not a guarantee that a trade will continue or become profitable.

TradingView Pine Script ADX Indicator showing trend strength measurement

Read the three outputs​

+DI and -DI summarize positive and negative directional movement relative to true range. Comparing them provides directional context. ADX smooths their normalized difference and measures strength. A falling ADX can occur while price continues in the same direction.

Levels such as 20 or 25 are conventional filters. They are not universal boundaries between a tradable trend and a range. Increasing the smoothing period changes responsiveness; it does not establish a better result for every market.

Complete v6 indicator​

ta.dmi(diLength, adxSmoothing) returns a three-value tuple in the order +DI, -DI, ADX. This existing example plots all three and adds reference levels:

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Pineify

//@version=6
indicator(title="ADX Trend Strength Monitor", shorttitle="ADX", format=format.price, precision=2, overlay=false)

// Input parameters
len = input.int(14, minval=1, title="DI Length", tooltip="Period for directional movement calculation")
lensig = input.int(14, title="ADX Smoothing", minval=1, maxval=50, tooltip="Smoothing period for ADX line")

// Calculate ADX and directional indicators
[diplus, diminus, adx] = ta.dmi(len, lensig)

// Plot the indicators
plot(adx, color=color.red, linewidth=2, title="ADX")
plot(diplus, color=color.lime, title="+DI")
plot(diminus, color=color.orange, title="-DI")

// Add horizontal reference lines
hline(25, "ADX 25", color=color.gray, linestyle=hline.style_dashed)
hline(50, "ADX 50", color=color.gray, linestyle=hline.style_dashed)

// Color background based on trend strength
bgcolor(adx > 50 ? color.new(color.green, 90) : adx > 25 ? color.new(color.yellow, 95) : color.new(color.red, 95))

The background is green above 50, yellow above 25 through 50, and red at 25 or below. These colors describe the chosen thresholds, not long/short directions. The example has no order commands or alert conditions.

Define a testable filter​

A possible rule is to allow a separately specified long entry only when +DI exceeds -DI and ADX is above a chosen threshold. State whether you mean ADX is merely above that level or has just crossed it; those produce different trades.

Compare the entry rule with and without the filter using the same dates, fees and execution timing. Include trends the filter misses and entries delayed by smoothing. Do not select a shorter length solely because it looks better on one chart.

Position size should follow the loss budget and instrument exposure. A high ADX alone does not justify increasing it: a strong trend can still reverse or gap through a stop. If requesting higher-timeframe DMI, distinguish developing values from confirmed values before interpreting alerts.

The earlier AAPL, EURUSD, TSLA and SPY anecdotes were not accompanied by reproducible trades. They are not evidence for a preferred setting or improved performance.

Sources checked October 20, 2026: TradingView DMI and Pine v6 reference.