OPEN-SOURCE SCRIPT

ADX Filtered Average True Range

251
Overview

This indicator combines ATR-based volatility measurement with ADX directional filtering to highlight only those moments when volatility expansion is aligned with confirmed trend momentum. Raw ATR measures how much price moves per bar, but a rising ATR alone says nothing about direction or conviction. By layering an ADX filter on top, the indicator separates meaningful expansion — where volatility is growing in the direction of a strengthening trend — from choppy noise where volatility rises without directional follow-through.

The result is a two-signal system displayed in a separate pane: a smoothed ATR line that changes colour only when the trend is directionally confirmed, and a background highlight that activates only when all three conditions align — expanding ATR, a rising directional ADX signal, and a bar that closes in the direction of the trend. This gives traders a compact, at-a-glance read on whether current volatility is actionable or should be ignored.

The indicator is designed for swing and intraday traders on instruments with clear trending behaviour, such as NIFTY, BANKNIFTY, CRUDEOIL1!, and major crypto pairs.

How It Works

ATR is calculated by applying the selected smoothing method to the true range series. A second SWMA pass (smoothed ATR, atrs) acts as a baseline — when raw ATR rises above atrs and atrs itself is also rising, the indicator treats volatility as actively expanding:

Pine Script®
atr = ma_function(ta.tr(true), atrlen) atrs = ta.swma(atr) ATRExpanding = (atrs > atrs[1] and atr > atrs)


The ADX filter uses Pine's native
Pine Script®
ta.dmi()
to compute DI+, DI−, and raw ADX. A SWMA of ADX (sadx) acts as the directional baseline. Bullish ADX is confirmed when sadx is rising, ADX is above sadx, DI+ shows momentum or dominance over DI−, and DI+ is above 15. Bearish ADX mirrors this using DI−:

Pine Script®
sadx = ta.swma(adx) ADXUp = sadx > sadx[1] and adx > sadx and (diplus > diplus[1] or diplus > diminus) and diplus > 15 ADXDn = sadx > sadx[1] and adx > sadx and (diminus > diminus[1] or diminus > diplus) and diminus > 15


Background highlighting only fires when all three conditions are simultaneously true — expanding volatility, directional ADX confirmation, and a bar closing in the expected direction.

Colour key:
  • Dark red line — raw ATR; always visible as the volatility baseline
  • Thick white line — smoothed ATR (SWMA of ATR); the trend-adjusted volatility baseline
  • Green background — ATR expanding + bullish ADX confirmed + bullish bar (close > open)
  • Red background — ATR expanding + bearish ADX confirmed + bearish bar (close < open)
  • No background — ATR contracting, or ADX directional filter not met, or bar indecisive


Inputs

  1. ATR – Length — Number of bars used to smooth the true range for ATR calculation. Constrained to the Fibonacci sequence for harmonic alignment. Low (e.g. 5): fast, reactive ATR that tracks short-term volatility spikes. High (e.g. 55): slow, structural ATR that filters out minor fluctuations. Default: 13.
  2. Smoothing — MA method applied to the true range when computing ATR. RMA (Wilder's moving average) is the industry standard and matches most platform ATR implementations. SWMA is the most responsive with zero lag; VWMA incorporates volume weight. Default: RMA.
  3. ADX – Length — Lookback period for the DMI/ADX calculation via
    Pine Script®
    ta.dmi()
    . Low (e.g. 8): ADX responds faster, triggers more frequently but with more false positives. High (e.g. 55): ADX requires sustained directional pressure before confirming. Default: 34.
  4. ADX – Smoothing — Smoothing period applied inside
    Pine Script®
    ta.dmi()
    to derive the signal line (lensig). Low (e.g. 1): raw, unsmoothed ADX. High (e.g. 13): heavily smoothed ADX that lags but reduces whipsaws. Default: 3.


Usage Notes

  • A green or red background is a confluence signal, not a standalone entry. Use it to confirm setups identified on your primary chart — price action, structure, or another trend tool.
  • When the background is absent despite a strong price move, treat this as a caution flag. Either ATR is contracting (move may be running out of energy) or ADX disagrees with direction (possible counter-trend move).
  • The DI threshold of 15 acts as a minimum directional noise filter. In low-volatility instruments or compressed consolidation phases, ADX rarely satisfies this condition — this is intentional behaviour, not a bug.
  • The Fibonacci-constrained length inputs encourage harmonic consistency across ATR and ADX settings. Consider pairing lengths that share a ratio — for example ATR 13 with ADX 34, or ATR 21 with ADX 55.
  • On shorter timeframes (1m–5m), set ATR Length to 5 or 8 and ADX Length to 13 or 21 for responsive signals. On daily or weekly charts, 34/89 or 55/144 combinations work well.
  • This indicator plots in a separate pane. Keep your price chart uncluttered — the background colour bleeds through to the main chart, providing context without requiring you to watch the pane constantly.


Recommended Pairings

This indicator pairs well with a trend-following overlay such as a Hull MA, VWAP, or a multi-timeframe EMA ribbon to confirm the broader bias before the background activates. Volume indicators — particularly Volume Delta or On-Balance Volume — add a useful layer of confirmation when the background fires, helping distinguish absorption-driven moves from thin-market noise. For Indian derivative traders, pairing with an open-interest change indicator on NIFTY or BANKNIFTY options can sharpen entry timing during background signals.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.