# Ehlers Bandpass Filter

Also known as: Band-pass filter, Digital resonator.
A Statistics concept (Ehlers DSP cluster) in the LuxAlgo Library, with 2 indicator implementations.

## What is the Ehlers bandpass filter?

The Ehlers bandpass filter is a second-order recursive filter, published by John Ehlers, that is tuned to one cycle period and a bandwidth around it. Price components near the chosen period pass with little attenuation (exactly none at the center), while slower ones (trend) and faster ones (bar-to-bar noise) are attenuated, so the output is a zero-mean oscillator tracing the selected cycle. In signal-processing terms it is a resonator, a two-pole filter whose response peaks at the center period.

Ehlers published the code in 'Corona Charts' (Technical Analysis of Stocks & Commodities, November 2008) and reused it in 'Empirical Mode Decomposition' with Ric Way (March 2010), with the bar midpoint as input, a 20-bar center period and a half-bandwidth of 0.1, which passes cycles of roughly 18 to 22 bars. It reappears in his later work, including Cycle Analytics for Traders (2013).

Bandwidth is the central tradeoff. A narrow band is selective but has a long memory: in Ehlers' words it can 'ring out like a bell' once energized. A wider band follows a changing cycle faster but admits more trend and noise. At the center period the filter adds no phase shift; off-center components are attenuated and shifted, so when the market's cycle drifts from the tuned period, the output's turns drift from price's.

## How it's calculated

One recursion with coefficients derived from the center period and the bandwidth (angles in degrees, as in Ehlers' code):

```
β = cos(360 / P)
γ = 1 / cos(720 × δ / P)
α = γ - sqrt(γ^2 - 1)
BP_t = 0.5 × (1 - α) × (x_t - x_(t-2)) + β × (1 + α) × BP_(t-1) - α × BP_(t-2)

  x_t: input price at bar t (Ehlers uses (high + low) / 2)
  P: center period in bars (default 20)
  δ: half-bandwidth as a fraction of P (default 0.1, passing roughly P × (1 ± δ))
  β: cosine term placing the center period
  γ: bandwidth term
  α: pole coefficient; closer to 1 means a narrower band and longer ringing
  BP_t: bandpass output at bar t
  t: current bar
```

The x_t - x_(t-2) term zeroes the response to a constant level, so the output centers on zero; 0.5 × (1 - α) scales the gain to exactly 1 at the center period.

Some code takes the full bandwidth BW = 2δ, with γ = 1 / cos(360 × BW / P); the filter is the same. LuxAlgo's Normalized Resonator uses this full-width input.

Seed BP at 0 for the first two bars; narrow bands need many warm-up bars.

## How traders use it

- Cycle timing: turns and zero crossings of the output mark the swings of the tuned cycle, used when the market is ranging and a cycle is actually present.
- Normalized for fixed thresholds: raw output swells and shrinks with volatility. LuxAlgo's Normalized Resonator runs the filter on the bar midpoint (100-bar center period and 0.5 bandwidth by default), divides it by its highest absolute value over a window tied to the center period, adds a 9-period EMA signal line, and labels signal-line crosses beyond ±0.8.
- Side-by-side comparison: the band-pass row of the [Swiss Army Knife filter](https://www.luxalgo.com/library/concept/swiss-army-knife-filter/) is this filter, so the Library's Swiss Army Knife Filter build can run it next to other responses on identical code.
- With honest limits: in strong trends the tuned cycle carries little of the move, and the oscillator can swing while price trends.

## Ehlers bandpass filter vs related cycle tools

- **Roofing Filter** (https://www.luxalgo.com/library/concept/roofing-filter/): Also a bandpass, but a wide one built from a high-pass stage and a SuperSmoother to prepare data for other indicators. The Ehlers bandpass is a narrow resonant filter that isolates one cycle and is read directly.
- **Swiss Army Knife Filter** (https://www.luxalgo.com/library/concept/swiss-army-knife-filter/): The general second-order recursion with swappable coefficients. Its band-pass row is this filter; the dedicated version fixes that row and exposes period and bandwidth.
- **Dominant Cycle Measurement** (https://www.luxalgo.com/library/concept/dominant-cycle-measurement/): Measurement estimates which period is strongest; the bandpass isolates a period once chosen. Filter-bank estimators run many bandpasses and keep the one with the most power.

## FAQ

### What bandwidth should I use on the Ehlers bandpass filter?

A narrow half-bandwidth such as Ehlers' default 0.1 suits a cycle whose period you know well; wider settings such as 0.5 suit an uncertain or drifting period, at the cost of more trend and noise. Very narrow bands keep ringing after the cycle fades.

### What period should the bandpass be tuned to?

The period of the cycle you expect to trade. Ehlers' examples default to 20 bars, but a fixed choice works only while that cycle persists, which is why many traders set it from [dominant cycle measurement](https://www.luxalgo.com/library/concept/dominant-cycle-measurement/).

### Does the Ehlers bandpass filter lag?

Not at the center period, where it adds no phase shift. Cycles longer or shorter than the center come through attenuated and shifted, so lag appears whenever the market's actual cycle differs from the tuned one. The filter is causal and does not repaint.

## Implementations in the Library

- Normalized Resonator (LuxAlgo): https://www.luxalgo.com/library/indicator/normalized-resonator/
- Swiss Army Knife Filter (LuxAlgo): https://www.luxalgo.com/library/indicator/swiss-army-knife-filter/

## Related concepts

- Dominant Cycle Measurement: https://www.luxalgo.com/library/concept/dominant-cycle-measurement/
- Sinewave Indicator: https://www.luxalgo.com/library/concept/sinewave-indicator/
- Roofing Filter: https://www.luxalgo.com/library/concept/roofing-filter/
- Decycler: https://www.luxalgo.com/library/concept/decycler/
- Even-better Sinewave: https://www.luxalgo.com/library/concept/even-better-sinewave/
- Adaptive-parameter Technique: https://www.luxalgo.com/library/concept/adaptive-parameter-technique/
- Autocorrelation Periodogram: https://www.luxalgo.com/library/concept/autocorrelation-periodogram/

---

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