Bitcoin Power Law Bayesian Fit with Residual Histogram

Description:
This Pine Script implements a Bitcoin (BTC) price indicator based on a power-law relationship between BTC price and time, modeled using Bayesian regression.
Bayesian regression is one of the most robust regression methods.
The indicator provides a robust framework for understanding BTC price trends, highlighting key statistical levels, based on deviation from the power law trend and visualizing the bimodal nature of BTC price behavior through a residual distribution histogram (distribution of the deviation from the Bayesian power law trend).
Features:
Power Law Model with Confidence Levels:
Models BTC price as a power-law function of time using Bayesian regression, displaying the median trendline.
Includes multiple confidence intervals to reflect statistical uncertainty.
Plots a support power-law line, set at 2 standard deviations below the median trend, serving as a critical lower bound for price expectations.
Bimodal Residual Histogram:
Displays a histogram in a lower panel, illustrating the distribution of model residuals (difference between actual BTC price and the power-law model) over a default 100-day window (user-configurable). This is one of the most innovative components of this indicator because it highlights the current shape of the distribution of recent deviations.
Highlights the bimodal nature of BTC price behavior, with two distinct regimes:
Core Power Law: Represents periods (approximately 2 years) when BTC price closely follows the power-law trend, typically when below the median power-law line.
Turbulent Flow BTC: Captures periods when BTC price is above the median power-law line, exhibiting more chaotic, bull-run behavior.
The histogram provides a range of possible prices based on the observed residual distribution, aiding in probabilistic price forecasting.
These analogies with fluid dynamics are part of the power law framework based on parallels in financial physics.
Purpose:
This indicator is designed for traders and analysts seeking to understand BTC price dynamics through a statistically grounded power-law model. The confidence levels and support line offer clear benchmarks for trend and support analysis, while the bimodal histogram provides insight into whether BTC is in a stable "Core Power Law" phase or a volatile "Turbulent Flow" phase, enabling better decision-making based on market regime.
Usage Notes:
Use the histogram to determine whether BTC is in the Core Power Law (below the power-law trend) or Turbulent Flow (above the trend) regime to contextualize price behavior.
Adjust the residual window (default 100 days) to analyze different timeframes for the distribution.
The support power-law line (2 standard deviations below) serves as a critical level for identifying potential price floors.
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi Quantonomyfund secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.
Penafian
Skrip jemputan sahaja
Hanya pengguna yang diberikan kebenaran oleh penulis mempunyai akses kepada skrip ini dan ini selalunya memerlukan pembayaran. Anda boleh menambahkan skrip kepada kegemaran anda tetapi anda hanya boleh menggunakannya selepas meminta kebenaran dan mendapatkannya daripada penulis — ketarhui lebih lanjut di sini. Untuk lebih butiran, ikuti arahan penulis di bawah atau hubungi Quantonomyfund secara terus.
TradingView tidak menyarankan pembayaran untuk atau menggunakan skrip kecuali anda benar-benar mempercayai penulisnya dan memahami bagaimana ia berfungsi. Anda juga boleh mendapatkan alternatif sumber terbuka lain yang percuma dalam skrip komuniti kami.
Arahan penulis
Amaran: sila baca panduan kami untuk skrip jemputan sahaja sebelum memohon akses.