What it does
ADX Trend Strength shows Welles Wilder's Average Directional Index (ADX) together with the two directional indicators, +DI and -DI. ADX measures how strong a trend is, regardless of direction; the DI lines show which side is in control.
This version colors ADX by strength band (weak, developing, trending, strong) and fades it when ADX is falling. It marks +DI / -DI crosses, optionally only when ADX shows enough trend strength, and alerts when ADX moves above or below the trend threshold.
How it works
TradingView's ta.dmi function provides the standard calculation:
- +DM and -DM are the parts of today's range that extend beyond yesterday's high or low (only the larger one counts, and only if positive).
- +DI = 100 × smoothed +DM ÷ smoothed true range; -DI likewise.
- DX = 100 × |+DI − -DI| ÷ (+DI + -DI). ADX is a smoothed average of DX.
Bands: ADX below 20 is grey (weak), 20–25 yellow (developing), 25–40 blue (trending) and 40+ purple (strong). A falling ADX is drawn more transparent.
Signals: a bullish cross when +DI crosses above -DI, a bearish cross when -DI crosses above +DI. With the filter on, a cross only counts when ADX is at or above the minimum. A small circle marks ADX rising through the trend threshold. All signals are evaluated on closed bars.
How to use it
- Use ADX as a regime filter. Below 20, many trend-following setups perform poorly and range tactics may fit better. Rising through 25 indicates a trend is building.
- A falling ADX above 40 often means a strong trend is losing pace, not that it has reversed.
- DI crosses give direction. They are more meaningful when ADX is rising at the time of the cross.
- Combine with price structure and your risk management plan. Works across liquid markets from M30 to D1.
Settings
| Input | Default | What it changes |
|---|---|---|
| DI length | 14 | Responsiveness of +DI and -DI. |
| ADX smoothing | 14 | Responsiveness of ADX. |
| Weak / developing boundary | 20 | Lower band edge. |
| Trend threshold | 25 | Trending band edge and threshold alerts. |
| Strong trend level | 40 | Strong band edge. |
| Filter DI crosses by ADX | On | Ignores crosses when ADX is low. |
| Minimum ADX for DI cross | 20 | Level used by the filter. |
Limitations
- ADX is heavily smoothed and lags. It often confirms a trend only after a large part of the move.
- ADX does not show direction. A high reading can belong to a strong downtrend just as easily as an uptrend.
- DI lines cross frequently in ranges; the ADX filter reduces this but cannot remove it.
- The band levels are conventions, not rules, and can behave differently on volatile instruments such as crypto or around news.
Pine Script source
In TradingView open Pine Editor, paste the code, click Save and then Add to chart.
FXP_AdxTrendStrength.pine
61 lines
// © FXPIPS ONLINE — https://fxpips.online/tradingview-indicators/adx-trend-strength/
// License: MIT. Educational tool — not financial advice. Trading involves substantial risk.
//@version=6
// ADX / DMI with color-coded trend-strength bands and +DI / -DI cross signals that can be
// filtered by a minimum ADX reading. Signals confirm on bar close.
indicator("FXP ADX Trend Strength", shorttitle = "FXP ADX", overlay = false)
// ── Inputs ─────────────────────────────────────────────────────────────
grpA = "ADX / DMI"
diLen = input.int(14, "DI length", minval = 1, group = grpA)
adxSmooth = input.int(14, "ADX smoothing", minval = 1, group = grpA)
grpB = "Strength bands"
weakLevel = input.float(20.0, "Weak / developing boundary", minval = 1.0, group = grpB)
trendLevel = input.float(25.0, "Trend threshold", minval = 1.0, group = grpB)
strongLevel = input.float(40.0, "Strong trend level", minval = 1.0, group = grpB)
grpS = "Signals"
useFilter = input.bool(true, "Filter DI crosses by ADX", group = grpS)
filterLevel = input.float(20.0, "Minimum ADX for DI cross", minval = 0.0, group = grpS)
grpV = "Display"
colPlus = input.color(#26a69a, "+DI", group = grpV)
colMinus = input.color(#ef5350, "-DI", group = grpV)
colWeak = input.color(#9e9e9e, "ADX: weak", group = grpV)
colDev = input.color(#fbc02d, "ADX: developing", group = grpV)
colTrend = input.color(#2962ff, "ADX: trending", group = grpV)
colStrong = input.color(#7b1fa2, "ADX: strong", group = grpV)
// ── Calculation ────────────────────────────────────────────────────────
[diPlus, diMinus, adx] = ta.dmi(diLen, adxSmooth)
adxRising = adx > adx[1]
adxBase = adx >= strongLevel ? colStrong : adx >= trendLevel ? colTrend : adx >= weakLevel ? colDev : colWeak
adxColor = adxRising ? adxBase : color.new(adxBase, 45)
adxOk = not useFilter or adx >= filterLevel
bullCross = ta.crossover(diPlus, diMinus) and adxOk and barstate.isconfirmed
bearCross = ta.crossunder(diPlus, diMinus) and adxOk and barstate.isconfirmed
trendStart = ta.crossover(adx, trendLevel) and barstate.isconfirmed
trendFade = ta.crossunder(adx, trendLevel) and barstate.isconfirmed
// ── Plots ──────────────────────────────────────────────────────────────
plot(adx, "ADX", color = adxColor, linewidth = 3)
plot(diPlus, "+DI", color = colPlus)
plot(diMinus, "-DI", color = colMinus)
hWeak = hline(weakLevel, "Weak boundary", color = color.new(colWeak, 50), linestyle = hline.style_dotted)
hTrend = hline(trendLevel, "Trend threshold", color = color.new(colTrend, 40), linestyle = hline.style_dashed)
hStrong = hline(strongLevel, "Strong level", color = color.new(colStrong, 50), linestyle = hline.style_dotted)
fill(hWeak, hTrend, color = color.new(colDev, 92), title = "Developing band")
plotshape(bullCross, "+DI crosses above -DI", style = shape.triangleup, location = location.bottom, color = colPlus, size = size.small)
plotshape(bearCross, "-DI crosses above +DI", style = shape.triangledown, location = location.top, color = colMinus, size = size.small)
plotshape(trendStart, "ADX crosses trend threshold", style = shape.circle, location = location.bottom, color = colTrend, size = size.tiny)
// ── Alerts ─────────────────────────────────────────────────────────────
alertcondition(bullCross, "Bullish DI cross", "+DI crossed above -DI on {{ticker}} ({{interval}})")
alertcondition(bearCross, "Bearish DI cross", "-DI crossed above +DI on {{ticker}} ({{interval}})")
alertcondition(trendStart, "ADX above trend threshold", "ADX rose above the trend threshold on {{ticker}} ({{interval}})")
alertcondition(trendFade, "ADX below trend threshold", "ADX fell below the trend threshold on {{ticker}} ({{interval}})")

