Files
QuanTAlib/lib/channels/uchannel/uchannel.md
T
86fe32a682 SIMD Refactor: Merge simd-dev into dev (#55)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
Co-authored-by: Warp <agent@warp.dev>
2026-01-18 19:02:03 -08:00

9.0 KiB
Raw Blame History

UCHANNEL: Ultimate Channel

Overview and Purpose

The Ultimate Channel, developed by John F. Ehlers, is a channel indicator designed to offer minimal lag. It draws inspiration from Keltner Channels, which typically use an Exponential Moving Average (EMA) for the centerline and Average True Range (ATR) to establish channel width. Both the EMA and the ATR's own averaging introduce lag. The Ultimate Channel aims to mitigate this by replacing these averaging processes with Ehlers' Ultrasmooth Filter.

The channel is constructed by:

  1. Calculating a "Smoothed True Range" (STR). The "True Range" for this indicator is specifically defined by Ehlers as TrueHigh - TrueLow.
    • TrueHigh (TH): The Close of the previous bar if it is higher than the High of the current bar; otherwise, it is the High of the current bar. (TH = Max(High, Close[1]))
    • TrueLow (TL): The Close of the previous bar if it is lower than the Low of the current bar; otherwise, it is the Low of the current bar. (TL = Min(Low, Close[1])) This TH - TL range is then smoothed using the Ultrasmooth Filter with a dedicated length (STRLength).
  2. Calculating a centerline by applying the Ultrasmooth Filter to the source price (typically close) with its own length (Length).
  3. Plotting the upper and lower channel bands by adding/subtracting a multiple (NumSTRs) of the Smoothed True Range (STR) from the centerline.

The primary purpose is to provide traders with dynamic support and resistance levels that are highly reactive to price action, aiming for nearly zero lag due to the comprehensive use of the Ultrasmooth Filter.

Core Concepts

  • Dual Ultrasmooth Filtering: Both the centerline and the range component (STR) are smoothed using the Ehlers Ultrasmooth Filter, contributing to the indicator's responsiveness and reduced lag.
  • Ehlers' True Range Definition: Utilizes a specific definition of True Range (Max(High, Close[1]) - Min(Low, Close[1])) as the basis for volatility measurement, which is then smoothed to create STR, rather than using a traditional ATR calculation.
  • Volatility-Adaptive Width: The channel width is directly proportional to the Smoothed True Range (STR), causing it to expand in volatile markets and contract in calmer ones.
  • Minimal Lag: A key design goal, aiming to provide more timely signals compared to traditional channel indicators like Keltner Channels.

Common Settings and Parameters

Parameter Default Function When to Adjust
Source close The price series for the centerline calculation (e.g., Close). Typically close, but can be adjusted.
High Source high The high price series for True High calculation. Standard high.
Low Source low The low price series for True Low calculation. Standard low.
STR Length 20 Lookback period for smoothing the TH - TL range to get STR. Shorter lengths make STR more reactive; longer lengths make STR smoother.
Length 20 Lookback period for smoothing the Source (e.g., Close) to get the centerline. Shorter lengths make the centerline more responsive; longer lengths provide smoother channel limits but will moderately increase indicator lag.
STR Multiplier 1.0 Multiplier for the Smoothed True Range (STR) to determine channel width. Smaller values create tighter channels; larger values create wider channels.

Calculation and Mathematical Foundation

Simplified explanation:

  1. Determine the True High (TH) for each bar: TH = Max(Current High, Previous Close).
  2. Determine the True Low (TL) for each bar: TL = Min(Current Low, Previous Close).
  3. Calculate the bar's specific range: Range = TH - TL.
  4. Smooth this Range series using the Ehlers Ultrasmooth Filter with STRLength to get the Smoothed True Range (STR).
  5. Smooth the Source price (e.g., Close) using the Ehlers Ultrasmooth Filter with Length to get the Centerline.
  6. The Upper Channel is Centerline + (NumSTRs × STR).
  7. The Lower Channel is Centerline - (NumSTRs × STR).

Technical formula (based on Ehlers' description):

  1. True High (TH): TH[i] = Max(High[i], Close[i-1]) (Note: The Pine Script implementation uses src_centerline[i-1] which is typically Close[i-1])

  2. True Low (TL): TL[i] = Min(Low[i], Close[i-1])

  3. Range Series (RS): RS[i] = TH[i] - TL[i]

  4. Smoothed True Range (STR): STR = UltrasmoothFilter(RS, STRLength)

  5. Centerline: Centerline = UltrasmoothFilter(Close, Length) (or specified Source)

  6. Upper Channel: UpperChannel = Centerline + (NumSTRs × STR)

  7. Lower Channel: LowerChannel = Centerline - (NumSTRs × STR)

🔍 Technical Note: The Ehlers Ultrasmooth Filter is the core engine, applied independently to two different series: the calculated TH-TL range and the input Source price. The responsiveness of the channel comes from this dual application of a low-lag filter, aiming to mitigate lag found in traditional ATR and EMA calculations of Keltner Channels.

Interpretation Details

  • Reduced Lag: The primary characteristic, offering quicker signals than traditional Keltner Channels. The channel aims for "nearly zero lag."
  • Dynamic Support/Resistance: The Upper Channel can act as resistance, and the Lower Channel as support.
  • Volatility Indication: The width of the channel (determined by STR) reflects market volatility. Wider channels mean higher volatility.
  • Trend Following: Trades can be initiated based on breakouts from the channel or by following the direction of the centerline.
  • Smoothing Channel Limits: The channel limits can be made smoother by increasing the input Length parameter (for the centerline). Doing this will moderately increase the indicator lag.
  • Comparison to Ultimate Bands: Ehlers notes that the Ultimate Channel indicator does not differ from the Ultimate Band indicator in any major fashion.

Use and Application

The Ultimate Channel can be used similarly to Keltner Channels for interpreting price action, with the key advantage of reduced lag.

Example Trading Strategy (from John F. Ehlers, applicable to both Ultimate Channel and Bands):

  • Hold a position in the direction of the Ultimate Smoother (the centerline).
  • Exit that position when the price "pops" outside the channel in the opposite direction of the trade.
  • This is described as a trend-following strategy with an automatic following stop.

Performance Profile

Operation Count (Streaming Mode, per Bar)

Ultimate Channel uses dual Ultrasmooth Filters (4-pole IIR) for centerline and STR:

Operation Count Cost (cycles) Subtotal
ADD/SUB 12 1 12
MUL 18 3 54
CMP/MAX/MIN 2 1 2
Total 32 ~68 cycles

Breakdown:

  • True High/Low (2 comparisons): 2 CMP = 2 cycles
  • Range calculation: 1 SUB = 1 cycle
  • Ultrasmooth Filter #1 (STR, 4-pole): 4 ADD + 8 MUL = 28 cycles
  • Ultrasmooth Filter #2 (Centerline, 4-pole): 4 ADD + 8 MUL = 28 cycles
  • Band calculation: 2 ADD + 2 MUL = 8 cycles

Complexity Analysis

Mode Complexity Notes
Streaming O(1) Two IIR filters with constant state
Batch O(n) Linear scan, IIR sequential

Memory: ~96 bytes (two 4-pole filter states, previous close)

SIMD Analysis

Optimization Applicable Notes
AVX2 vectorization Dual 4-pole IIR recursive dependencies
FMA IIR coefficients benefit from FMA
Batch parallelism IIR filters inherently sequential

Note: Both Ultrasmooth Filters use 4-pole IIR structures with strong recursive dependencies, preventing SIMD parallelization.

Quality Metrics

Metric Score Notes
Accuracy 9/10 Dual Ehlers filters provide excellent smoothing
Timeliness 9/10 Designed for near-zero lag
Overshoot 8/10 Ultrasmooth minimizes overshoot
Smoothness 9/10 4-pole filters extremely smooth

Limitations and Considerations

  • Lag (Minimized but Present): While designed for minimal lag, some inherent delay from the smoothing process will still exist, especially if Length is increased for smoother bands.
  • Parameter Sensitivity: Performance can be sensitive to the STRLength, Length, and NumSTRs parameters. These may need tuning for different instruments or timeframes.
  • Whipsaws: In choppy or sideways markets, the high responsiveness might lead to more frequent false signals or whipsaws.
  • Not a Standalone System: It's generally advisable to use the Ultimate Channel in conjunction with other indicators or analytical techniques for confirmation.

References

  • Ehlers, J. F. (2024, April). The Ultimate Smoother. Stocks & Commodities Magazine. (This article is referenced in the context of the Ultimate Channel's components).
  • Ehlers, J. F. (General). Various publications on advanced filtering and cycle analysis. (e.g., "Rocket Science for Traders", "Cycle Analytics for Traders").