This script creates a colorful view of Bitcoin's price action, where different colors indicate the time until the next halving date. The color scale in the top right highlights what each main color group represents in terms of days until the next halving. Using historical data, the simple indication of days until the next halving has somewhat accurately predicted potential bottoms and tops of market cycles. Comparing current colors to previous cycles provides a rough view of where BTC is in its current cycle and what to expect going forward until the next halving date.
In addition to the colored price action, I have incorporated the stock-to-flow model price for Bitcoin.
The stock-to-flow (S2F) model price:
The stock-to-flow ratio is a calculation that aims to estimate how many years are required to produce the current stock of an asset, based on the current production rate. When applied to Bitcoin, we simply divide the total amount of bitcoins in circulation by the amount of bitcoins mined in a certain timeframe. Once we have this value, we can calculate a model price based on the stock-to-flow ratio. This S2F model price uses a 463-day moving average. Preston Pysh came up with this number as he believed Bitcoin cycles happen in three phases: bull run, correction, and a reversion to the mean. He estimated there are about 200,000 blocks per cycle, three phases per cycle, and ~144 blocks per day. Dividing all three gets us 463. I have removed 1,000,000 coins from this calculation to account for Satoshi's coins.
The process I took to plot this model price (credit to PlanB for originally creating this calculation):
-Declare constant variables for the halving period, starting block reward, and the number of coins Satoshi owns. -Fetch the block index by using the request.security() function. -Determine the number of halvings that have occurred by dividing the block index by the halving period. -Calculate the current block reward by multiplying the initial block reward by 0.5 raised to the power of the number of halvings. -Calculate the number of blocks mined per period (day or week) and derive the stock (total bitcoins in circulation minus Satoshi's coins) and flow (annual block rewards) from it. -Calculate the S2F ratio by dividing the stock by the flow. -Calculate the S2F model price by applying a mathematical formula (ModelPrice = exp(-1.84) * S2F to the power of 3.36) along with a 463-day moving average.
** Please note, due to the use of the 463-day MA, the first ~400 days of the S2F model price is not entirely accurate.
In addition to the above, I have added vertical lines on each halving date, along with labels that have a tooltip if you hover over them, which will show more information about that particular halving.
Important tips:
-This script has been designed to work on the 1-Day timeframe but can also work on the 1-Week timeframe. Any other timeframe will not accurately plot all the information due to the way I have developed the script. -This script is best used on the ticker I have posted this on, "INDEX:BTCUSD". It can also work on "BLX" or "BITSTAMP:BTCUSD". -Hide candles when using the script to just show the halving rainbow (hover over the symbol name in the top left and press the eye icon). -Right-click the price scale and select "Scale price chart only" to get a better view of the plots. -Right-click the price scale and select "Logarithmic." -I will update the script as time goes on to show future halvings along with adjusting the next halving date as we get closer (if it changes).
Settings Menu: Tooltips are included explaining what the settings do, but here's a quick summary:
-'Show Vertical Halving Lines?': Default is true. This allows the user to remove the vertical lines shown on each halving date. -'Show Halving Labels?': Default is true. This allows the user to remove the info labels shown on each halving date. -'Halving Line and Label Color': Default is white. This allows the user to change the color of the halving lines and labels to better fit their chart layout. -'Show Stock to Flow Model Price?': Default is true. This allows the user to remove the S2F model price. -'Stock to Flow Model Price Color': Default is white. This allows the user to change the color of the S2F model price to better fit their chart layout. -'Draw Color Table?': Default is true. This allows the user to remove the color table in the top right of the chart. -'Distance rainbow is away from actual price action': Default is 0 (Plots over candles). This allows the user to adjust where the halving rainbow is plotted if they would like to also see candles on the chart. (Use any value under 0.9)
Feel free to message me or comment on the post with any questions or issues!
Skrip ini dipublikasikan secara closed-source dan anda dapat menggunakannya dengan bebas. Anda dapat memfavoritkannya untuk digunakan pada grafik. Anda tidak dapat melihat atau mengubah kode sumbernya.
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.