OPEN-SOURCE SCRIPT
Bitcoin MA Quantile Bands | Astral Vision

Bitcoin MA Quantile Bands | Astral Vision 🌠💠
This indicator constructs a dynamic price channel around a configurable moving average by computing the statistical distribution of the log ratio between Bitcoin's price and its MA over a long historical lookback, then mapping specific percentiles of that distribution back into price-space bands. The result is a set of bands that adapt to Bitcoin's actual historical price behavior relative to its trend, rather than using fixed multipliers or standard deviations.
Calculation ⚙️
The moving average is computed on daily Bitcoin price data over a configurable length, with an optional 2-day mode that doubles the effective lookback. Five MA types are available: SMA, EMA, WMA, VWMA, and HMA. The Hull Moving Average is computed as WMA(2 × WMA(src, len/2) - WMA(src, len), sqrt(len)), which reduces lag significantly compared to a standard WMA of the same length.
For each bar, the log ratio is computed as log(price / MA). This transforms the multiplicative relationship between price and MA into an additive one, making the distribution symmetric and comparable across different price magnitudes. A price trading 50% above its MA produces the same absolute log ratio as a price trading 50% below, which a raw ratio would not.
Six percentiles of this log ratio series are then computed over the configurable quantile lookback window using linear interpolation: the 1st, 10th, 35th, 65th, 90th, and 99th percentiles. Each percentile is converted back to a price level by multiplying the MA by the exponential of that percentile value: band price = MA × exp(percentile). This inversion ensures the bands are always centered on the current MA value and scale proportionally with price.
The resulting six levels represent: the 1st percentile (historic bottoms, price has been lower than this only 1% of historical bars), the 10th percentile (oversold), the 35th and 65th percentiles (fair value range, price spends roughly 30% of its time between these two), the 90th percentile (overbought), and the 99th percentile (historic peaks).
The indicator can be computed on 1-day or 2-day bars, with the 2-day mode doubling both the MA length and the quantile lookback to maintain structural equivalence.
Plots 📊
Inputs 🎛️
Colors 🎨
5 Astral Vision presets + custom override. Default: Paradiso.
Purpose 🎯
Standard Bollinger Bands use fixed standard deviation multiples, which assume a normal distribution of price deviations around the mean. Bitcoin's price distribution relative to its trend is not normal: it has a heavy right tail during bull markets and periodic extreme downside excursions. Computing bands from actual historical percentiles of the log ratio captures this asymmetry directly, placing the overbought and oversold bands exactly where they have historically been meaningful rather than at a theoretically symmetric distance. The log transformation further ensures that the bands scale correctly with price across Bitcoin's full history, avoiding the distortion that linear band methods produce when comparing early and recent market cycles.
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.
This indicator constructs a dynamic price channel around a configurable moving average by computing the statistical distribution of the log ratio between Bitcoin's price and its MA over a long historical lookback, then mapping specific percentiles of that distribution back into price-space bands. The result is a set of bands that adapt to Bitcoin's actual historical price behavior relative to its trend, rather than using fixed multipliers or standard deviations.
Calculation ⚙️
The moving average is computed on daily Bitcoin price data over a configurable length, with an optional 2-day mode that doubles the effective lookback. Five MA types are available: SMA, EMA, WMA, VWMA, and HMA. The Hull Moving Average is computed as WMA(2 × WMA(src, len/2) - WMA(src, len), sqrt(len)), which reduces lag significantly compared to a standard WMA of the same length.
For each bar, the log ratio is computed as log(price / MA). This transforms the multiplicative relationship between price and MA into an additive one, making the distribution symmetric and comparable across different price magnitudes. A price trading 50% above its MA produces the same absolute log ratio as a price trading 50% below, which a raw ratio would not.
Six percentiles of this log ratio series are then computed over the configurable quantile lookback window using linear interpolation: the 1st, 10th, 35th, 65th, 90th, and 99th percentiles. Each percentile is converted back to a price level by multiplying the MA by the exponential of that percentile value: band price = MA × exp(percentile). This inversion ensures the bands are always centered on the current MA value and scale proportionally with price.
The resulting six levels represent: the 1st percentile (historic bottoms, price has been lower than this only 1% of historical bars), the 10th percentile (oversold), the 35th and 65th percentiles (fair value range, price spends roughly 30% of its time between these two), the 90th percentile (overbought), and the 99th percentile (historic peaks).
The indicator can be computed on 1-day or 2-day bars, with the 2-day mode doubling both the MA length and the quantile lookback to maintain structural equivalence.
Plots 📊
- Configurable moving average line
- Historic Peaks band at the 99th percentile with fill to Overbought
- Overbought band at the 90th percentile
- Oversold band at the 10th percentile with fill to Historic Bottoms
- Historic Bottoms band at the 1st percentile
Inputs 🎛️
- Timeframe: 1D or 2D bar mode
- MA Length: lookback period for the moving average
- MA Type: SMA, EMA, WMA, VWMA, or HMA
- Quantile Lookback: historical window over which percentiles are computed
Colors 🎨
5 Astral Vision presets + custom override. Default: Paradiso.
Purpose 🎯
Standard Bollinger Bands use fixed standard deviation multiples, which assume a normal distribution of price deviations around the mean. Bitcoin's price distribution relative to its trend is not normal: it has a heavy right tail during bull markets and periodic extreme downside excursions. Computing bands from actual historical percentiles of the log ratio captures this asymmetry directly, placing the overbought and oversold bands exactly where they have historically been meaningful rather than at a theoretically symmetric distance. The log transformation further ensures that the bands scale correctly with price across Bitcoin's full history, avoiding the distortion that linear band methods produce when comparing early and recent market cycles.
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の精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
My premium indicators are available on Whop:
whop.com/astralvision
Astral Vision 🌠💠
whop.com/astralvision
Astral Vision 🌠💠
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
My premium indicators are available on Whop:
whop.com/astralvision
Astral Vision 🌠💠
whop.com/astralvision
Astral Vision 🌠💠
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。