# Range Filter

Also known as: Range Filter [DW], Range Filter Buy and Sell.
A Trend concept (Trend-following systems) in the LuxAlgo Library.

## What is a Range Filter?

A range filter is a trend line that moves only when price travels farther from it than a volatility-scaled threshold, holding flat through noise and stepping with real moves. If price sits more than the threshold above the line, the line rises to price minus the threshold; if more than the threshold below, it falls to price plus the threshold; otherwise it stays put. The result is a staircase with a binary direction, up after the last step higher and down after the last step lower.

The best-known version is DonovanWall's Range Filter, published in 2018 as an open-source script on TradingView and described by its author as an experimental study to filter out minor price action. Its threshold borrows the volatility filter of the [QQE](https://www.luxalgo.com/library/concept/qqe/), applied to price instead of a smoothed RSI: in the widely ported form, an exponential average of absolute bar-to-bar changes, smoothed again and scaled by a multiplier. Later revisions added ATR, standard-deviation and percent-of-price thresholds, and popular buy-and-sell adaptations turned the direction flips into signals.

Mathematically the update is soft-thresholding: the line moves by the part of price's distance that exceeds the threshold, and not at all inside it. That separates it from a moving average, which moves a little on every bar, and from trailing stops like [NRTR](https://www.luxalgo.com/library/concept/nrtr/) or [Supertrend](https://www.luxalgo.com/library/concept/supertrend/), which jump to the other side of price. LuxAlgo's Proximal Range Filter generalizes the rule with a 200-period ATR threshold and an adaptation rate that blends a predicted step with the new price before thresholding; at a rate of 1 it reduces exactly to the classic filter.

## How to read a range filter

The chart shows the line, its direction, and the target bands that say what it would take to move it.

1. Read direction from the last step: up is bullish, down is bearish, and flat bars keep the previous state.
2. Read flat stretches as noise: while price stays within one threshold of the line, nothing new has happened.
3. Read the target bands, the line plus and minus the threshold, as the prices the next bar must reach to move the filter; a step against the prevailing direction is the flip.

## How it's calculated

A gated price filter: the line moves only by the part of price's distance from it that exceeds a volatility threshold.

```
AC_t = EMA_n(abs(x_t - x_(t-1)))
r_t = m × EMA_(2n-1)(AC)_t
F_t = x_t - r_t, if x_t - r_t > F_(t-1)
F_t = x_t + r_t, if x_t + r_t < F_(t-1)
F_t = F_(t-1), otherwise
Bands: F_t + r_t and F_t - r_t
Dir_t = +1 if F_t > F_(t-1), -1 if F_t < F_(t-1), else Dir_(t-1)

  t: bar index
  x_t: source price at bar t (commonly the close)
  AC_t: average absolute bar-to-bar change of the source
  EMA_n: exponential moving average over n bars
  n: sampling period
  m: range multiplier
  r_t: threshold at bar t
  F_t: range filter value at bar t
  Dir_t: direction state at bar t
```

Lines 3 to 5 equal F_t - F_(t-1) = sign(d) × max(abs(d) - r_t, 0) with d = x_t - F_(t-1), the soft-threshold form.

Lines 1 and 2 are the QQE-style threshold of the widely ported version; ATR, standard-deviation or percent-of-price thresholds slot into r_t unchanged, and published ports ship different default periods and multipliers.

The filter is causal and does not repaint; the current bar's value settles at the close.

## How traders use it

- As a trend-state gate: entries from faster tools are taken long only while the filter's last step was up and short only while it was down.
- As a signal line: buy-and-sell adaptations fire on direction flips confirmed by a close on the new side; flips cluster when the threshold is small for the market's noise.
- As levels: flat segments of the staircase mark prices the market has not left far enough to reset, read as support or resistance the next push must clear.
- As an exit: in an up state, a close below the lower band means the line is about to step down, a volatility-scaled exit that sits still through pullbacks smaller than the threshold.

## Range Filter vs related trend lines

- **Supertrend** (https://www.luxalgo.com/library/concept/supertrend/): Supertrend builds ATR bands around each bar's median price and flips its line from one side of price to the other. A range filter has no sides: it follows price at up to one threshold's distance, a filtered price path rather than a stop.
- **NRTR** (https://www.luxalgo.com/library/concept/nrtr/): NRTR trails a fixed deviation from the trend's extreme and reverses when crossed. The range filter measures its gate from its own last value, not from an extreme, so it can step either way on any bar where price travels far enough.
- **ATR Trailing Regime** (https://www.luxalgo.com/library/concept/atr-trailing-regime/): An ATR trailing regime ratchets a stop line in the trend's favor until breached. ATR-scaled range filters look similar, but the line is a price estimate that moves both ways, not a one-way ratchet.
- **EMA** (https://www.luxalgo.com/library/concept/ema/): An EMA moves on every bar by a fraction of price's distance from it. A range filter moves on few bars, by all of the distance beyond its threshold: still through noise, one threshold behind during trends.

## FAQ

### Who created the Range Filter indicator?

DonovanWall published Range Filter [DW] as an open-source TradingView script in 2018, adapting the QQE's volatility filter to price. Many community versions followed, including popular buy-and-sell signal adaptations.

### Does the range filter repaint?

No. Each value depends only on the current bar and the filter's previous value, so history never redraws; the live bar can still step until it closes.

### What settings work best for a range filter?

None universally. A larger multiplier or longer sampling period widens the threshold, giving fewer steps and later flips; a smaller one hugs price and whipsaws in ranges. Published ports ship different defaults, so tune on the market you trade.

### How does LuxAlgo's Proximal Range Filter relate to the classic version?

It keeps the gate and adds a prediction step and an adaptation rate, with a threshold of 200-period ATR times a multiplier. At an adaptation rate of 1 it computes the classic range filter exactly; lower rates ease the line toward price instead of jumping.

## Related concepts

- Supertrend: https://www.luxalgo.com/library/concept/supertrend/
- Parabolic SAR: https://www.luxalgo.com/library/concept/parabolic-sar/
- Chandelier Stop: https://www.luxalgo.com/library/concept/chandelier-stop/
- Donchian Trend Rules: https://www.luxalgo.com/library/concept/donchian-trend-rules/
- ATR Trailing Regime: https://www.luxalgo.com/library/concept/atr-trailing-regime/
- Gann HiLo Activator: https://www.luxalgo.com/library/concept/gann-hilo-activator/
- Alligator: https://www.luxalgo.com/library/concept/alligator/
- NRTR: https://www.luxalgo.com/library/concept/nrtr/
- Chande Kroll Stop: https://www.luxalgo.com/library/concept/chande-kroll-stop/
- Halftrend: https://www.luxalgo.com/library/concept/halftrend/

---

Source: https://www.luxalgo.com/library/concept/range-filter/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/