Files
QuanTAlib/lib/channels/uchannel/uchannel.md
T
Miha Kralj 90d5638008 Add new moving average implementations: LTMA, MCNMA, NLMA, NMA, NYQMA, RAIN, and TRAMA
- LTMA (Linear Trend Moving Average): Introduces a predictive moving average using dual cascaded EMAs for trend estimation.
- MCNMA (McNicholl EMA): Implements a zero-lag TEMA using a cascaded EMA structure for enhanced responsiveness.
- NLMA (Non-Lag Moving Average): Utilizes a damped cosine kernel to achieve reduced lag in moving averages.
- NMA (Natural Moving Average): Adapts smoothing based on volatility profiles using a square-root kernel.
- NYQMA (Nyquist Moving Average): Applies the Nyquist-Shannon theorem to prevent aliasing in cascaded moving averages.
- RAIN (Rainbow Moving Average): Combines multiple SMA layers with weighted averages for multi-scale smoothing.
- TRAMA (Trend Regularity Adaptive Moving Average): Adapts smoothing based on the frequency of new highs and lows in price data.
2026-02-20 21:40:32 -08:00

5.9 KiB

UCHANNEL: Ehlers Ultimate Channel

Ehlers Ultimate Channel applies the Ultrasmooth Filter (USF) twice: once to the close price for the centerline and once to True Range for band width, creating a channel where both the trend estimate and the volatility measure share the same low-lag, zero-overshoot filter characteristics. Unlike UBANDS which uses RMS of price residuals, UCHANNEL uses Smoothed True Range (STR) for band width, making it responsive to gap-inclusive volatility. Separate period parameters allow independent tuning of centerline smoothness and band-width responsiveness.

Historical Context

John F. Ehlers introduced the Ultimate Channel in 2024 as the natural companion to his Ultimate Bands (UBANDS) indicator. The two share the same USF foundation but differ in how they determine band width:

  • UBANDS: measures RMS of price deviations from the USF centerline (statistical dispersion)
  • UCHANNEL: smooths True Range with the USF (range-based volatility)

The True Range approach captures overnight gaps, making UCHANNEL more appropriate for markets with significant gap activity (equities, futures) where the high-low range alone would underestimate actual price risk.

The design philosophy reflects Ehlers' preference for using the same high-quality filter throughout an indicator system. By applying the USF to both the centerline and the True Range, all components share consistent lag characteristics and zero-overshoot behavior.

Architecture & Physics

1. True Range

True Range extends the high-low range to capture gaps:


TR_t = \max(H_t,\, C_{t-1}) - \min(L_t,\, C_{t-1})

This formulation ensures gap-ups (today's low above yesterday's close) and gap-downs (today's high below yesterday's close) are fully captured.

2. Ultrasmooth Filter Coefficients

Each USF instance derives its coefficients from a period parameter n:


\text{arg} = \frac{\sqrt{2}\,\pi}{n}

c_2 = 2\,e^{-\text{arg}} \cos(\text{arg}), \qquad c_3 = -e^{-2\,\text{arg}}, \qquad c_1 = \frac{1 + c_2 - c_3}{4}

3. USF Recursion

The 2-pole IIR recursion applied to input series X:


\text{USF}_t = (1 - c_1)\,X_t + (2c_1 - c_2)\,X_{t-1} - (c_1 + c_3)\,X_{t-2} + c_2\,\text{USF}_{t-1} + c_3\,\text{USF}_{t-2}

This recursion is applied twice with potentially different periods:

  • To close prices → centerline (Middle band)
  • To True Range → Smoothed True Range (STR)

4. Channel Construction


\text{Middle}_t = \text{USF}(C_t,\; n_{\text{center}})

\text{STR}_t = \text{USF}(TR_t,\; n_{\text{str}})

U_t = \text{Middle}_t + k \cdot \text{STR}_t

L_t = \text{Middle}_t - k \cdot \text{STR}_t

where k is the multiplier (default 1.0).

5. Complexity

Streaming: O(1) per bar. Both USF instances are IIR recursions requiring only four multiply-adds each plus scalar state. No buffers or window scans needed. Memory: approximately 200 bytes for the two USF states plus metadata.

Mathematical Foundation

Parameters

Symbol Name Default Constraint Description
n_{\text{str}} strPeriod 20 \geq 1 USF period for smoothing True Range
n_{\text{center}} centerPeriod 20 \geq 1 USF period for smoothing the centerline
k multiplier 1.0 > 0 STR multiplier for band width

USF Transfer Function


H(z) = \frac{(1 - c_1) + (2c_1 - c_2)\,z^{-1} - (c_1 + c_3)\,z^{-2}}{1 - c_2\,z^{-1} - c_3\,z^{-2}}

Frequency response: cutoff at approximately f_c \approx 1/(2\pi n) cycles per bar; 12 dB/octave rolloff.

Pseudo-code

function uchannel(close[], high[], low[], strPeriod, centerPeriod, multiplier):
    // compute USF coefficients for STR
    arg_s = sqrt(2) * pi / strPeriod
    c2_s = 2 * exp(-arg_s) * cos(arg_s)
    c3_s = -exp(-2 * arg_s)
    c1_s = (1 + c2_s - c3_s) / 4

    // compute USF coefficients for centerline
    arg_c = sqrt(2) * pi / centerPeriod
    c2_c = 2 * exp(-arg_c) * cos(arg_c)
    c3_c = -exp(-2 * arg_c)
    c1_c = (1 + c2_c - c3_c) / 4

    usf_str  = [NaN, NaN]   // two-element state
    usf_cen  = [NaN, NaN]

    for each bar t:
        // True Range
        th = max(high[t], close[t-1])
        tl = min(low[t], close[t-1])
        tr = th - tl

        // USF for True Range → STR
        if usf_str not initialized:
            str_val = tr
        else:
            str_val = (1-c1_s)*tr + (2*c1_s-c2_s)*tr[t-1]
                      - (c1_s+c3_s)*tr[t-2]
                      + c2_s*usf_str[0] + c3_s*usf_str[1]
        usf_str = [str_val, usf_str[0]]

        // USF for close → centerline
        if usf_cen not initialized:
            center = close[t]
        else:
            center = (1-c1_c)*close[t] + (2*c1_c-c2_c)*close[t-1]
                     - (c1_c+c3_c)*close[t-2]
                     + c2_c*usf_cen[0] + c3_c*usf_cen[1]
        usf_cen = [center, usf_cen[0]]

        upper = center + multiplier * str_val
        lower = center - multiplier * str_val

        emit (upper, center, lower)

UCHANNEL vs UBANDS

Aspect UBANDS UCHANNEL
Centerline USF of close USF of close
Band width RMS of residuals (O(n)) USF of True Range (O(1))
Gap sensitivity Indirect (via residuals) Direct (True Range includes gaps)
Parameters 1 period 2 periods (STR, center)
Per-bar cost O(n) O(1)

Output Interpretation

Output Interpretation
Centerline rising USF-filtered uptrend
STR increasing Smoothed True Range expanding; volatility rising
Band width contracting Volatility compression
Price beyond upper Extreme positive deviation from USF trend

Resources

  • Ehlers, J. F. (2024). "Ultimate Channel." Technical Analysis of Stocks & Commodities.
  • Ehlers, J. F. (2013). Cycle Analytics for Traders. Wiley.
  • Ehlers, J. F. (2001). Rocket Science for Traders. Wiley.