Free: indicator teardowns, a repaint checker and open-source scripts. No buy/sell signals, ever.

Taught to TradeSystems over signals.

Explainers / ADX and DI

ADX and DI, explained from the source

"ADX and DI for v4" by BeikabuOyaji is one of the most-boosted free scripts on TradingView, with more than 45,000 boosts. It draws three lines: a green DI+, a red DI- and a navy ADX, plus a flat line at 20. Its DI+ and DI- are the standard ones, but its ADX is not: it averages DX with a simple 14-bar average instead of Wilder's smoothing, so it will not match TradingView's built-in DMI indicator.

How to read the three lines

The usual reading is: DI+ above DI- means upward movement has dominated, DI- above DI+ means downward, and ADX above a threshold (this script draws 20) means that dominance has been strong. Those are descriptions of the past 14 bars, not forecasts.

What the code does

StepThis scriptTradingView's built-in DMI
True range, +DM, -DMstandard Wilder definitionsthe same
Smoothing of TR, +DM, -DMWilder's running sum (sum - sum/14 + new)Wilder's average (RMA)
DI+ and DI-smoothed DM / smoothed TR x 100the same
DX\DI+ - DI-\/ (DI+ + DI-) x 100the same
ADXsimple 14-bar average of DXWilder's average (RMA) of DX

The running sum is 14 times the Wilder average, and the 14 cancels when DM is divided by TR, so DI+ and DI- come out the same as the built-in once the start of the chart is behind you. In our simulation they matched to the 13th decimal place, and every DI cross fell on the same bar.

The ADX is where they part. A simple average gives each of the last 14 DX values equal weight and drops the 15th entirely; Wilder's average keeps a fading memory of all of them. On the same prices, in our simulation:

So if you compare this script with the built-in DMI, or with ADX on another platform, a different number is expected. Neither is a bug; they are two definitions.

The start of the chart

The script fills missing previous values with zero. On the very first bar of the chart, "previous close" is therefore 0, so that bar's true range and +DM are the whole price. That oversized first value fades by 13/14 each bar. In our test series (prices near 100, bars about 1% wide) DI+ and DI- were more than 1 point off for the first 76 to 83 bars, and ADX over its first 40 bars was off by about 50 points on average. The warm-up is longer when the bars are narrow compared with the price.

This only matters where the chart starts: a newly listed symbol, a monthly or weekly chart with little history, or the first screen of a long backtest. Ignore the first hundred or so bars.

The settings

SettingDefaultWhat it does
len14the length of the DI smoothing and of the ADX average
th20where the flat line is drawn; nothing else uses it

One length drives both steps. The built-in DMI lets you set DI length and ADX smoothing separately.

Does it repaint?

No more than any indicator calculated on the current bar. It uses no higher-timeframe data. While a bar is open, its DI and ADX values move with price and settle when the bar closes, so a cross seen mid-bar can disappear. More in what repainting is and how to check a script yourself.

Where it fails

Also explained: Supertrend · Squeeze Momentum · CM MacD MTF · Repainting

Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. ADX and DI for v4 is by BeikabuOyaji on TradingView, published under the Mozilla Public License 2.0; this page explains its published open-source code and is not affiliated with the author. Simulation figures come from synthetic random-walk prices and say nothing about how the indicator trades.

Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts, Nadaraya-Watson Envelope, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, Twin Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Support and Resistance (High Volume Boxe, Trendline Breakouts With Targets by Char, Breakout Finder by LonesomeTheBlue

Next steps

  • Get a script fixed. Compiles but behaves differently live, or changes after a reload? In a Pine Script Audit, an AI model reads every line and writes a report on what to fix for $49, or also fixes those problems for $149. It cannot prove a script is safe.
  • Check your own script. Paste its source into the free repaint checker. It runs in your browser and flags known patterns.
Subscribe to the Teardown Letter: $19/moBack to Taught to Trade

No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.