> "The best filters are those that eliminate the noise while preserving the signal. The Ultrasmooth Filter does this with remarkable precision, making it the ideal foundation for volatility bands."
Ehlers Ultimate Bands (UBANDS) represent John Ehlers' 2024 evolution of volatility-based channel indicators, replacing the conventional SMA foundation with his Ultrasmooth Filter (USF)—a 2-pole IIR filter with exceptional noise rejection and zero-lag properties. The bands are defined by the RMS (Root Mean Square) of residuals between price and the smooth, providing a mathematically rigorous measure of deviation that adapts to actual price behavior rather than assuming normal distributions.
John F. Ehlers introduced the Ultimate Bands in 2024 as part of his ongoing research into digital signal processing applied to financial markets. Unlike Bollinger Bands (which use SMA + standard deviation), Ultimate Bands leverage the Ultrasmooth Filter—a filter Ehlers developed to achieve superior smoothing with minimal lag.
The key insight behind Ultimate Bands is that traditional standard deviation measures assume stationarity and normality—assumptions that financial time series routinely violate. By instead measuring the RMS of the actual residuals (the difference between price and the smoothed value), the bands adapt to whatever distribution the market presents, making no assumptions about the shape of returns.
This implementation faithfully reproduces Ehlers' published formula while adding production-grade features: NaN handling, bar correction support, and multiple calculation modes (streaming, batch, span).
where $P_t$ is the input price and $n$ is the period parameter.
**Implementation note:** We precompute the coefficients $k_0 = 1 - c_1$, $k_1 = 2c_1 - c_2$, and $k_2 = -(c_1 + c_3)$ for FMA optimization, reducing the hot path to four fused multiply-add operations.
### 2. Residual Calculation
The residual measures the deviation between price and the smooth:
$$
r_t = P_t - \text{USF}_t
$$
This captures the "noise" component that the filter rejected—the very component that defines volatility in Ehlers' framework.
### 3. RMS-Based Bands
Unlike standard deviation (which requires mean subtraction), RMS operates directly on the residuals:
\text{Upper}_t = \text{USF}_t + k \cdot \text{RMS}_t
$$
$$
\text{Lower}_t = \text{USF}_t - k \cdot \text{RMS}_t
$$
where $k$ is the multiplier parameter (default 1.0).
**Why RMS instead of StdDev?** Standard deviation measures dispersion around the mean; RMS measures dispersion around zero. Since our residuals are already deviations from the smooth (which serves as our "center"), RMS is the mathematically correct measure. For residuals with zero mean, RMS equals StdDev—but RMS is computationally cheaper (no mean calculation) and more robust when residuals have non-zero drift.
## Mathematical Foundation
### USF Transfer Function
In the z-domain, the Ultrasmooth Filter has transfer function:
The modest improvement reflects the IIR nature of USF—recursion blocks parallelization. The value of this indicator lies in its mathematical properties (zero lag, RMS bands), not raw computational speed.
- **Streaming mode:** Incremental updates via `Update(TValue, isNew)`
- **Batch mode:** TSeries-based calculation via `Update(TSeries)`
- **Span mode:** Direct span-to-span calculation via `Calculate(ReadOnlySpan, Span, Span, Span)`
- **Consistency check:** All three modes produce identical results
- **Middle band verification:** Matches standalone USF implementation exactly
**Note:** As a proprietary Ehlers indicator (2024), Ultimate Bands are not yet implemented in common open-source libraries. Our validation relies on the PineScript reference and mathematical verification against the USF filter implementation.
## Common Pitfalls
1.**Warmup Period Awareness**: UBANDS requires $n$ bars before the USF stabilizes and RMS buffer fills. For $n=20$, the first 19 bars produce valid but not fully "hot" output. `IsHot` transitions to `true` at bar $n$.
**Formula:**
$$
\text{WarmupPeriod} = n
$$
**Impact:** Early bars may show artificially narrow bands (insufficient residual history). Always check `IsHot` in production.
2.**Multiplier Interpretation**: The default multiplier is 1.0 (not 2.0 like Bollinger Bands). This is because RMS of residuals is typically larger than standard deviation of prices—the filter explicitly captures what standard deviation only approximates. Adjust multiplier based on signal-to-noise requirements.
3.**IIR Filter Initialization**: The USF requires several bars to "spin up." During the first 3 bars, we return the input value directly (no filtering). This prevents the explosive behavior that IIR filters can exhibit with zero-initialized state.
4.**Computational Cost (IIR vs FIR)**: Unlike FIR filters (SMA, WMA), the USF cannot be parallelized due to its recursive nature. Each output depends on previous outputs. This is the tradeoff for zero-lag performance.
**Cost comparison:**
$$
\text{SMA: } O(1) \text{ per bar (running sum)}
$$
$$
\text{USF: } O(1) \text{ per bar (fixed recursion)}
$$
Both are O(1), but USF has higher constant factor (~4 FMA vs ~1 ADD/SUB).
5.**Memory Footprint**: Each UBANDS instance maintains:
- USF state: 4 doubles (32 bytes)
- RingBuffer: $n$ doubles ($8n$ bytes)
- Metadata: ~100 bytes
**Total:**
$$
\text{Memory} \approx 8n + 132 \text{ bytes}
$$
For $n=20$: ~292 bytes/instance. Significantly smaller than dual-indicator designs (BBands: ~840 bytes).
6.**Zero Volatility Edge Case**: When all residuals are zero (price exactly tracks USF), RMS = 0 and bands collapse to the middle line. This is mathematically correct but rare in practice. The `Width` output makes this condition explicit.
7.**API Usage (isNew parameter)**: Critical for bar correction:
```csharp
// Correct
ubands.Update(openTick, isNew: true); // New bar
ubands.Update(midTick, isNew: false); // Same bar update
ubands.Update(closeTick, isNew: false); // Bar close