OPEN-SOURCE SCRIPT

Bitcoin WMA Bands | Astral Vision

509
Bitcoin WMA Bands | Astral Vision 💠🌠

This indicator constructs a volatility-adjusted band system around a Weighted Moving Average of price, using the standard deviation of logarithmic daily returns as the volatility measure rather than the standard deviation of price itself. The result is a channel whose width adapts dynamically to the current volatility regime, expanding during high-volatility periods and contracting during low-volatility ones, while remaining anchored to the WMA as the structural fair value reference.

Calculation ⚙️

The base reference line is a Weighted Moving Average of close over a configurable lookback in days. WMA weights recent bars more heavily than older ones using a linearly declining weight schedule, making it more responsive to recent price action than an SMA of the same length while being less erratic than an EMA.

The volatility measure is computed from logarithmic returns: for each bar, the log return is log(close / close[1]). The standard deviation of these log returns over a configurable lookback window is then multiplied by a configurable scale factor to produce the band half-width `s`. Using log returns rather than raw price changes ensures that the volatility measure is proportional across different price levels, making a 5% move at $10,000 and a 5% move at $100,000 contribute equally to the standard deviation.

The four bands are then computed as: band = WMA × exp(±n × s), where n is 1 or 2. The exponential transformation converts the log-space deviation back to price-space, ensuring the bands are multiplicatively symmetric around the WMA rather than additively symmetric. This means the upper and lower bands are equidistant in percentage terms rather than in absolute dollar terms.

The oscillator in the sub-panel is the log ratio of close to the WMA: log(close / WMA), which measures in log-space how far price has deviated from its trend. The same ±1σ and ±2σ levels are plotted in the sub-panel, allowing direct visual comparison of the oscillator's position within the band structure. Candles on the price chart are colored only when price is outside the ±1σ band, leaving them neutral in the fair value zone between the bands.

Crossover signals are generated when the oscillator crosses back inside the ±1σ boundary from outside: a triangle appears above the bar when the oscillator crosses back below the upper +1σ level from above, and below the bar when it crosses back above the lower -1σ level from below.

Plots 📊
  • WMA reference line on the price chart
  • Four volatility-adjusted bands at ±1σ and ±2σ on the price chart
  • Candle coloring on the price chart when price is outside the ±1σ band
  • Background color on the price chart between the ±1σ and ±2σ zones
  • Re-entry signals: triangle above bar on upper band exit, triangle below bar on lower band exit
  • Log-ratio oscillator in the sub-panel with matching ±1σ and ±2σ reference lines


Inputs 🎛️
  • STH Length: WMA lookback period in days
  • StDev Length: rolling window for the log return standard deviation
  • Band Scale: multiplier applied to the standard deviation before computing band width


Colors 🎨
5 Astral Vision presets + custom override. Default: Paradiso.

Purpose 🎯
Standard Bollinger Bands apply a fixed standard deviation multiple to a simple moving average computed on raw prices, which means the band width in percentage terms varies across different price levels and the bands do not correctly represent proportional deviations. This indicator applies the volatility measure in log-return space and converts back with the exponential function, producing bands that are geometrically consistent across Bitcoin's full price history. The WMA further reduces the lag of the central reference compared to an SMA, making the band system more responsive to trend changes without introducing the instability of shorter lookbacks.

Disclaimer ⭕️
This indicator is for informational and educational purposes only. It does not constitute financial advice. Past performance is not indicative of future results. Always do your own research before making investment decisions.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.