Trend indicator
ADX Calculator (Average Directional Index)
Compute the Directional Index (DX) from the +DI and -DI lines, the building block of ADX. Understanding what the system measures, trend strength regardless of direction, is the important part.
What the ADX is
The Average Directional Index is part of the Directional Movement system Wilder introduced in 1978. It answers a different question from most oscillators: not which way price is going, but how strongly it is trending at all. It is built in stages from the directional movement of each bar.
The positive and negative directional movement of each bar are smoothed with Wilder's method and divided by the smoothed True Range to produce the +DI and −DI lines, expressed as percentages. The directional index (DX) is then the absolute difference between +DI and −DI divided by their sum, times 100: it is large when one direction clearly dominates and small when the two are balanced. The ADX itself is Wilder's smoothed average of DX, which is why it responds slowly and needs a longer run of bars before it settles. This calculator shows the DX step from the two DI lines; the ADX is that value averaged over time.
Why the ADX is used
ADX is used to gauge trend strength so that other tools can be applied in the right context. Because it ignores direction, it is often read alongside the +DI and −DI lines, which indicate which side is in control. Wilder suggested that readings above 25 point to a trending market and readings below 20 to a weak or ranging one, with higher values indicating a stronger trend.
These thresholds are conventions, and the 14-period default is a starting point many adjust. What a given ADX level means for you is entirely your own call.
What are TradingView and Pine Script?
TradingView is one of the most widely used charting and market-analysis platforms, where traders and analysts study price movement across stocks, crypto, forex, and futures on interactive charts. Pine Script is TradingView's own lightweight programming language, created so anyone can build custom tools that run directly on those charts.
People use Pine Script to build four main kinds of tools. Indicators calculate and plot values on the chart, exactly like the calculation above, but recomputed automatically on every bar. Strategies add explicit entry and exit rules and can be backtested against historical data in TradingView's Strategy Tester to see how they would have behaved. Screeners scan many symbols at once for conditions you define. Alerts notify you the moment a condition you specified occurs, so you do not have to watch the screen.
The value is precision and automation. Instead of eyeballing a chart, you describe exactly what you want measured, visualized, or notified about, and TradingView runs it consistently across any market and timeframe. That is why traders, analysts, and developers write Pine Script: it turns a manual charting idea into a repeatable tool. These tools are for tracking, visualizing, and testing market ideas; they do not tell you what to trade, and that decision always remains yours.
Writing that code by hand means learning Pine Script's syntax, its type system, and the exact names of hundreds of built-in functions. It is a real programming language, and small mistakes stop a script from compiling in the Pine Editor.
Turn this into Pine Script
Here you computed the DX from the two DI lines. On a chart, ADX, +DI, and −DI all update every bar in a dedicated pane. Pine Script returns them together from ta.dmi(14, 14), but arranging the plots, coloring the directional lines, and building any trend filter or alert around them is the real work.
//@version=6
indicator("ADX / DMI", overlay=false)
[plusDI, minusDI, adxValue] = ta.dmi(14, 14)
plot(adxValue, "ADX", color=color.black)
plot(plusDI, "+DI", color=color.green)
plot(minusDI, "-DI", color=color.red)PineScripter is an AI built specifically for Pine Script. You describe what you want in plain English and it writes TradingView-ready v5 or v6 code. Because it is specialized on the Pine Script language and its exact function signatures, it tends to produce code that compiles far more reliably than general-purpose models like ChatGPT, which often invent functions that do not exist in Pine Script.
Related free calculators
From the blog
PineScripter is an AI developer tool that helps you write Pine Script code. It is not a financial advisor and will never offer financial, investment, or trading advice. Everything on this page, including the calculator and the explanations, is provided purely for educational and informational purposes. Any decision about how to interpret an indicator or trade a market is entirely your own. See our full disclaimer for more.