Skip to content
GetProfitable
Search
Trend

ADX Trend Strength

ADX in its own pane with a threshold line, the directional indicators behind it, and the background shaded for as long as trend strength stays above the threshold.

indicator
//@version=6
indicator("ADX Trend Strength", "ADX", format = format.price, precision = 1)

diLen = input.int(14, "DI length", minval = 1, group = "Settings")
smoothing = input.int(14, "ADX smoothing", minval = 1, group = "Settings")
threshold = input.int(25, "Trending above", minval = 1, maxval = 100, group = "Settings")
strongCol = input.color(#26A69A, "Trending", group = "Style")
quietCol = input.color(#787B86, "Not trending", group = "Style")
lineCol = input.color(#EF5350, "Threshold and DI minus", group = "Style")

[diPlus, diMinus, adx] = ta.dmi(diLen, smoothing)
trending = adx > threshold

plot(diPlus, "DI+", color = color.new(strongCol, 55))
plot(diMinus, "DI-", color = color.new(lineCol, 55))
plot(adx, "ADX", color = trending ? strongCol : quietCol, linewidth = 2)
hline(threshold, "Threshold", color = color.new(lineCol, 40), linestyle = hline.style_dashed)
bgcolor(trending ? color.new(strongCol, 90) : na, title = "Trending")

turnedStrong = ta.crossover(adx, threshold)
turnedQuiet = ta.crossunder(adx, threshold)
plotshape(turnedStrong, "Strength rose", location = location.bottom, style = shape.triangleup, color = strongCol, size = size.tiny)
plotshape(turnedQuiet, "Strength faded", location = location.top, style = shape.triangledown, color = quietCol, size = size.tiny)
alertcondition(turnedStrong, "ADX above threshold", "ADX rose above the trend strength threshold")
alertcondition(turnedQuiet, "ADX below threshold", "ADX fell back below the trend strength threshold")
This runs in TradingView, not here
Pine Script only executes inside TradingView. Paste the source into the Pine Editor and add it to a chart to see it plotted.

What it will not do

  • ADX measures how directional price has been, not which direction. A high reading fits a hard sell off as well as a rally.
  • It is an average of averages, so it turns up well after the move it is describing started and stays high well after that move ends.
  • The 25 threshold is convention. Quiet instruments rarely reach it and fast ones sit above it for weeks at a time.

Written from this description

Show ADX from ta.dmi in a separate pane with a configurable threshold line, plot DI plus and DI minus faintly behind it, shade the background while ADX is above the threshold, and alert on each crossing.

Educational only, not financial advice. The maths is simple arithmetic on the numbers you enter; it knows nothing about your broker, fees, slippage or the market. Something wrong with it? Say so in Site Feedback.