Data Analytic Investments
Trend & MomentumIntermediate

ADX

Average Directional Index

Quantifies trend strength — not direction — on a 0–100 scale.

4H, Daily
Crypto, Forex, Equities
Pine Script v5

What is it?

Also developed by Wilder in 1978, ADX measures the strength of a trend regardless of its direction. It is derived from two directional movement indicators: +DI (positive directional indicator) and -DI (negative directional indicator). ADX is the smoothed average of the absolute difference between +DI and -DI divided by their sum. Values below 20 indicate a weak or absent trend (range-bound market); 20–40 is a developing trend; above 40 is a strong trend; above 60 is an extremely strong trend. ADX rising means trend strength is increasing; ADX falling means it is weakening, even if price is still moving in the same direction.

When to use it

  • Filtering trade setups: only take trend-following signals (MACD crosses, EMA crossovers) when ADX is above 25, confirming a trend is in place.
  • Avoiding range-bound losses: when ADX is below 20, switch to mean-reversion strategies (RSI, Bollinger Bands) and avoid trend-following entries.
  • +DI/-DI crossovers: when +DI crosses above -DI with ADX above 20, it is a bullish directional signal; the reverse is bearish.
  • ADX peak and rollover: when ADX peaks above 40 and starts declining, the trend is losing momentum — consider tightening stops or reducing position size.
  • ADX slope: a steeply rising ADX from below 20 to above 25 is a strong signal that a new trend is beginning.

Common pitfalls

  • ADX does not indicate direction. An ADX of 50 could mean a strong uptrend or a strong downtrend — always check +DI vs -DI or price action for direction.
  • ADX lags significantly. By the time it confirms a trend above 25, a large portion of the initial move may already be over.
  • In crypto's 24/7 market, ADX can stay elevated for extended periods during parabolic moves, making the 'ADX peak = exit' rule unreliable without additional filters.
  • The 14-period default is very slow. Many crypto traders use 7 or 10 periods for faster response, at the cost of more false signals.
  • ADX below 20 does not mean price is flat — it means the directional movement is weak. Price can still make large moves in a choppy, non-trending fashion.

Free code template

Paste directly into TradingView Pine Editor → Add to chart.

Pine Script v5
/indicator("ADX — DAI Template", shorttitle="DAI ADX", overlay=false)

adxLen = input.int(14, "ADX Length", minval=1)
thresh = input.int(25, "Trend Threshold", minval=10)

[diPlus, diMinus, adxVal] = ta.dmi(adxLen, adxLen)

trending = adxVal >= thresh
adxColor = adxVal >= 40 ? #ef4444 : adxVal >= thresh ? #22c55e : #94a3b8

plot(adxVal,   "ADX",  color=adxColor, linewidth=2)
plot(diPlus,   "+DI",  color=color.new(#22c55e, 20), linewidth=1)
plot(diMinus,  "-DI",  color=color.new(#ef4444, 20), linewidth=1)
hline(thresh, "Trend Threshold", color=color.new(#fbbf24, 40), linestyle=hline.style_dashed)
hline(20, "Weak Trend", color=color.new(#94a3b8, 60), linestyle=hline.style_dotted)
bgcolor(trending ? color.new(#22c55e, 94) : color.new(#94a3b8, 96))

bullDI = ta.crossover(diPlus, diMinus) and adxVal > 20
bearDI = ta.crossunder(diPlus, diMinus) and adxVal > 20
plotshape(bullDI, "Bull DI Cross", shape.triangleup,   location.bottom, #22c55e, size=size.small)
plotshape(bearDI, "Bear DI Cross", shape.triangledown, location.top,    #ef4444, size=size.small)

alertcondition(ta.crossover(adxVal, thresh), "ADX Trend Start", "ADX crossed above " + str.tostring(thresh))