All indicators

Realized Volatility

Jul 29, 2019

Static chart image
Time BasedVolatility

The Realized Volatility indicator calculates the historical or realized volatility of an underlying asset while automatically scaling inputs to maintain consistency across different timeframes. This tool allows traders to view volatility metrics, such as a 30-day realized volatility, on intraday, daily, weekly, or monthly charts without manual period adjustments.

Usage

The Usage section focuses on how the script maintains a consistent volatility lookback regardless of the chart's timeframe. By default, the script is configured to reflect a 30-day historical volatility.

  • Intraday Scaling: If the chart is set to a 6-hour frequency, the indicator automatically rescales the lookback (e.g., 30 days * 4 units per day = 120 periods) to ensure the output still reflects the 30-day realized volatility.
  • Standard vs. EWMA: Users can toggle between standard variance calculations or an Exponentially Weighted Moving Average (EWMA) approach. The EWMA method places more weight on recent price action, which can be useful for identifying rapid changes in market regime.
  • Asset Basis: The tool automatically detects the asset type. It uses a 365-day basis for crypto and a 255-day basis for traditional markets (equities/forex) to account for trading day differences.

Details

The script calculates volatility by taking the natural log of the ratio between the current close and the previous close, squaring the result to find the variance. This variance is then summed over the adjusted lookback period, annualized using the detected basis, and square-rooted to produce the final percentage-based volatility figure.

Implementation details:

  • Timeframe Independence: It uses internal logic to calculate an adjustment factor based on whether the timeframe is intraday, weekly, or monthly.
  • Variance Calculation: Uses math.log(close / close[1]) to capture logarithmic returns, which is the industry standard for volatility modeling.

Settings

  • Lookback: Sets the target number of days for the volatility calculation (default is 30).
  • Use EWMA vol: A checkbox to toggle the Exponentially Weighted Moving Average calculation method.
  • EMA Decay Factor: Determines the decay rate for the EWMA calculation; lower numbers (2-5) are typically recommended for shorter-term responsiveness.

FAQ

How do I interpret a spike in Realized Volatility?

A spike indicates that the underlying asset's price is moving more significantly than it has in the recent past, signaling increased market activity or risk.

What is the difference between standard and EWMA volatility?

Standard volatility treats all days in the lookback period equally, while EWMA gives more significance to recent price moves, making it more responsive to current market conditions.

How can I access this tool?

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.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.