OPEN-SOURCE SCRIPT

Logarithmic Mean Reversion Bands | Astral Vision

673
Logarithmic Mean Reversion Bands | Astral Vision 🌠💠

This indicator computes Bollinger Bands in log-price space rather than raw price space, producing a statistically symmetric channel around the geometric mean of Bitcoin's price that correctly represents proportional deviations across all price levels and all market cycles. The oscillator in the sub-panel expresses the current price position in units of standard deviations from the log-mean, providing a normalized reading that is directly comparable regardless of where absolute price is trading.

Calculation ⚙️

The natural logarithm of Bitcoin's daily close price is taken for each bar. A simple moving average of this log-price series is computed over the configurable lookback window, producing the log-mean. The standard deviation of the log-price series over the same window is then computed.

The geometric mean line plotted on the price chart is the exponential of the log-mean: exp(log_mean). This is the geometric mean of price over the lookback window, which differs from the arithmetic mean in a meaningful way for assets with exponential growth trajectories. The geometric mean weights all proportional moves equally, so a period where price doubled from $1,000 to $2,000 contributes the same to the mean as a period where price doubled from $30,000 to $60,000, which is the correct treatment for a multiplicative process like Bitcoin's price.

The four band levels are computed as: exp(log_mean ± n × log_std), where n is 2.0 or 2.5. The exponential conversion ensures the bands are multiplicatively symmetric: the upper band is the same percentage above the geometric mean as the lower band is below it. This symmetry does not hold for standard Bollinger Bands computed on raw prices, where the upper band is a larger percentage above the mean than the lower band is below it.

The oscillator is the standardized log-price deviation: (log_price - log_mean) / log_std. This is dimensionless and equivalent to a Z-Score of the log-price series, measuring exactly how many standard deviations the current log-price sits above or below its rolling mean. A reading of +2.0 means log-price is two standard deviations above its mean, regardless of the absolute price level.

Reversal signals are generated when the oscillator crosses back inside the ±2.0 standard deviation boundary from outside: a downward triangle appears above the bar when the oscillator crosses back below +2.0 after being above it, and an upward triangle appears below the bar when it crosses back above -2.0 after being below it. These signals identify the moment when extreme deviation begins to revert, rather than the moment of maximum extension.

Plots 📊
  • Geometric mean line on the price chart
  • Four band lines at ±2.0σ and ±2.5σ on the price chart
  • Candle coloring on the price chart by band zone: full color outside ±2.5σ, reduced opacity between ±2.0σ and ±2.5σ, neutral between the bands
  • Z-Score oscillator in the sub-panel with matching ±2.0σ and ±2.5σ reference lines
  • Fill highlights when oscillator is beyond the outer ±2.5σ level
  • Static zone fills between the ±2.0σ and ±2.5σ levels
  • Reversal triangles on the price chart when oscillator crosses back inside the ±2.0σ boundary


Inputs 🎛️
  • Length: lookback window for the log-mean and log standard deviation
  • Plot Long/Short Signals: toggle the reversal triangle signals


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

Purpose 🎯
Standard Bollinger Bands applied to raw Bitcoin price produce bands that are not proportionally symmetric and whose standard deviation readings are not statistically consistent across different price levels. A +2σ reading at $1,000 and a +2σ reading at $50,000 on a raw-price Bollinger Band do not carry the same statistical weight because the distribution of raw price changes is not stationary across Bitcoin's history. Computing the bands in log space corrects this: the log-price distribution is much closer to stationary, making the standard deviation thresholds directly comparable across all cycles. The reversal signals add an entry timing dimension by marking the transition from extreme to normalizing rather than the peak of the extreme.

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提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。