HMA w/ SSE-Dynamic EWMA Volatility Bands
Oct 10, 2022

The HMA w/ SSE-Dynamic EWMA Volatility Bands indicator provides a dynamic volatility-based envelope centered around a Hull Moving Average (HMA) by optimizing the decay factor (lambda) for Exponentially Weighted Moving Average (EWMA) calculations.
Usage
The tool can be used to identify trend direction and potential price overextensions. The central HMA identifies the primary trend direction, changing color from green (bullish) to red (bearish). The surrounding bands expand and contract based on dynamic volatility, serving as potential support or resistance areas.
Key usage scenarios include:
- Trend Filtering: Use the color of the HMA to stay on the correct side of the market trend.
- Volatility Breakouts: Monitor price interactions with the upper and lower bands to identify high-momentum moves or mean reversion opportunities.
- Risk Assessment: Observe the annualized and daily volatility statistics in the dashboard to gauge current market risk.
Details
This script implements an advanced approach to volatility estimation. Instead of using a fixed lambda (such as the standard 0.94 used by RiskMetrics), it derives a dynamic lambda (λ) by minimizing the sum of squared errors (SSE) against the long-run variance (the one-year mean of squared log-returns).
The calculation process includes:
- Log Returns: Computing log(close / close[1]).
- Lambda Optimization: Iteratively finding the lambda value that best fits the historical data within a rolling window.
- EWMA Calculation: Applying the optimized lambda to derive daily volatility.
- Band Construction: Creating bands by multiplying the daily volatility by the source price and a user-defined multiplier, then centering them on an HMA.
- Annualization: Multiplying daily volatility by the square root of the trading days per year to provide standardized annualized volatility metrics.
Settings
General
- Source: The price source used for the HMA and volatility calculations.
- Lookback Period for Mean of Squared Log-returns: The window used to calculate the target variance for lambda optimization.
- Lookback Period for Mean of Lambda: The period over which the calculated lambda is averaged for the dashboard display.
- Days per Year: The number of trading days used to annualize volatility (e.g., 252 for stocks, 365 for crypto).
- HMA Period: The lookback period for the central Hull Moving Average.
- Use fast Log2 approximation?: When enabled, uses a faster mathematical approximation for log calculations to improve performance.
- Number of bars to calculate: Limits the historical lookback for the optimization algorithm to maintain script performance.
- Bands Volatility Multiplier: Adjusts the width of the volatility bands.
FAQ
How do I interpret the Mean of Lambda in the dashboard?
A higher lambda (closer to 1.0) indicates that the volatility estimate responds slowly to new price changes, emphasizing older data. A lower lambda means the indicator reacts more quickly to recent price shocks.
Why does the indicator only work on the daily timeframe?
The SSE-Dynamic logic is optimized for daily log-returns to avoid complexities involved in annualizing intraday volatility metrics and to ensure accuracy in the parameter estimation.
How can I access this indicator?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.