Hyperbolic Hull Moving Average (HHMA) [QuantAlgo]🟢 Overview
Hyperbolic Hull Moving Average is a trend-following indicator that replaces the linear weighting kernel inside a Hull Moving Average with a hyperbolic sine function, producing a moving average that concentrates weight on recent bars in a non-linear, exponentially accelerating curve rather than a straight ramp. Where a standard WMA assigns weight proportionally across the lookback, the sinh kernel creates a steep recency gradient that responds meaningfully to genuine momentum shifts while remaining more resistant to brief noise spikes, because distant bars lose influence at a compounding rate rather than a constant one. The result is a Hull-style construction with faster directional detection and smoother curvature than its conventional counterpart.
🟢 How It Works
The indicator is built across three passes of the same sinh weighting function. The core kernel computes a weighted average where each bar's weight is determined by the hyperbolic sine of its normalized position within the lookback, scaled by a tension parameter:
float _x = (_len - i) / _len * _t
float _w = (math.exp(_x) - math.exp(-_x)) / 2
Higher tension values push more of the total weight toward the most recent bars. At the default tension of 2.0 across a 24-period window, the most recent bar carries roughly 44 times the weight of the oldest bar. A standard WMA across the same window would assign the newest bar only 24 times the weight of the oldest, so the sinh kernel naturally produces a steeper bias toward recent price action at any equivalent length setting.
The Hull construction then runs two sinh-weighted averages at different periods, a fast pass at half the length and a slow pass at the full length, before combining them in the same denoising formula Alan Hull originally described:
fastSinh = f_sinh_weight(src, halfLen, tension)
slowSinh = f_sinh_weight(src, length, tension)
rawHull = 2 * fastSinh - slowSinh
hhma = f_sinh_weight(rawHull, sqrtLen, tension)
The raw Hull output is then passed through a final sinh-weighted smoothing pass at the square root of the full length, which removes the lagging noise the doubling step introduces.
Trend direction is determined by a simple slope check on the final output. This keeps state detection clean and unambiguous, with direction changes triggering alerts and visual updates the bar they occur.
🟢 Signal Interpretation
▶ Bullish Trend (Rising HHMA, Green): When the HHMA turns upward, all visual elements switch to the bullish colour, indicating a confirmed uptrend. Because the sinh kernel front-loads weight on recent bars, the line responds quickly to genuine upside momentum without needing price to sustain a move for many bars before registering a directional shift. Trend state remains bullish on each subsequent bar the HHMA continues to rise, allowing traders to hold positions through normal intra-trend oscillation without being shaken out by minor hesitations in the line.
▶ Bearish Trend (Falling HHMA, Red): When the HHMA turns downward, all visual elements switch to the bearish colour, confirming a downtrend or a breakdown from a prior uptrend. The same recency weighting that accelerates bullish detection also means the line will respond relatively quickly to sustained selling pressure, reducing the lag that causes conventional Hull variants to stay bullish well into a reversal. The trend remains bearish on each bar the HHMA continues to fall.
🟢 Features
▶ Preconfigured Presets: Three optimised parameter sets cover different trading approaches. "Default" is calibrated for swing trading on 4-hour and daily charts, balancing responsiveness with noise rejection. "Fast Response" shortens the lookback and increases recency bias for intraday and scalping use on 5-minute to 1-hour charts. "Smooth Trend" extends the period and flattens the weighting curve for position trading on daily and weekly charts where fewer, higher-conviction direction changes are preferred.
▶ Built-in Alerts: Three alert conditions support automated monitoring without requiring constant chart supervision. "Bullish Trend Signal" fires on the bar the HHMA slope turns upward. "Bearish Trend Signal" fires on the bar it turns downward. "Trend Direction Changed" covers both transitions with a single alert for traders who want a unified notification regardless of direction.
▶ Visual Customization: Six colour presets (Classic, Aqua, Cosmic, Cyber, Neon, and Custom) provide coordinated bullish and bearish colour pairs suited to different chart themes and backgrounds. Optional bar colouring tints price bars with the active trend colour at an adjustable transparency level, offering immediate visual confirmation of trend state across all open chart timeframes without requiring the indicator line itself to be in view.
Indicador Pine Script®






















