Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- // Thanks to Harold Christopher Burger and the anonymous @100trillionUSD twitter handle
- // Power Law inspired by https://medium.com/coinmonks/bitcoins-natural-long-term-power-law-corridor-of-growth-649d0e9b3c94
- // Stock-to-Flow inspired by https://medium.com/@100trillionUSD/modeling-bitcoins-value-with-scarcity-91fa0fc03e25
- // Bitcoin Never Look Back by https://medium.com/@cane.island/why-bitcoin-is-never-looking-back-f06ab333742e
- // Public Domain code
- // --- History (please update if you publish a new version) ---
- // 2019-09-21: First version
- // 2019-10-23: Added Bitcoin Never Look Back Price (NLBP)
- study(title="Bitcoin Power Law and stock to flow models", shorttitle="Power Law & Stock to Flow", overlay=true)
- showtop = input(title="Show Power Law top", type=input.bool, defval=true)
- showfit = input(title="Show Power Law regression fit", type=input.bool, defval=true)
- showbottom = input(title="Show Power Law bottom", type=input.bool, defval=true)
- showSF = input(title="Show Stock to Flow", type=input.bool, defval=true)
- shownlbp = input(title="Show Never Look Back Price", type=input.bool, defval=true)
- // Power law
- // Top
- atop=-13.38
- btop=5.02927337
- // Middle
- afit=-17.01593313
- bfit=5.84509376
- // Bottom
- abottom=-17.457
- bbottom=5.84509376
- // Some convenient constants
- blockperyear = 365.25*24*6
- blockperhalving = 365.25*24*6*4
- // Workaround to plot future where the chart doesn't go
- // We will call this function several times with a shift to reach "uncharted" areas
- calculate_series(atime, ashift) =>
- currenttime = atime + ashift
- // Number of days since Bitcoin Ledger start
- day = (currenttime-timestamp(2009, 01, 03, 00, 00))/(1000*3600*24)
- outtop = pow(10,atop+btop*log10(day))
- outfit = pow(10,afit+bfit*log10(day))
- outbottom = pow(10,abottom+bbottom*log10(day))
- // Number of days since NLBP model start
- dayNLB = (currenttime-timestamp(2010, 07, 17, 00, 00))/(1000*3600*24)
- // NLBP
- outnlbp = 0.018265*exp(0.2178*sqrt(dayNLB))
- // Stock to flow
- // Calculate stock
- stock = 0.0
- // Historical stock
- // Get Bitcoin circulating supply from 2009-01 till 2019-09 (monthly data at the start of each month)
- if currenttime >= timestamp(2009, 01, 01, 00, 00)
- stock := 50.0
- if currenttime >= timestamp(2009, 02, 01, 00, 00)
- stock := 137700.0
- if currenttime >= timestamp(2009, 03, 01, 00, 00)
- stock := 300350.0
- if currenttime >= timestamp(2009, 04, 01, 00, 00)
- stock := 485350.0
- if currenttime >= timestamp(2009, 05, 01, 00, 00)
- stock := 658050.0
- if currenttime >= timestamp(2009, 06, 01, 00, 00)
- stock := 818500.0
- if currenttime >= timestamp(2009, 07, 01, 00, 00)
- stock := 929300.0
- if currenttime >= timestamp(2009, 08, 01, 00, 00)
- stock := 1019550.0
- if currenttime >= timestamp(2009, 09, 01, 00, 00)
- stock := 1106550.0
- if currenttime >= timestamp(2009, 10, 01, 00, 00)
- stock := 1214700.0
- if currenttime >= timestamp(2009, 11, 01, 00, 00)
- stock := 1313750.0
- if currenttime >= timestamp(2009, 12, 01, 00, 00)
- stock := 1429450.0
- if currenttime >= timestamp(2010, 01, 01, 00, 00)
- stock := 1629350.0
- if currenttime >= timestamp(2010, 02, 01, 00, 00)
- stock := 1901200.0
- if currenttime >= timestamp(2010, 03, 01, 00, 00)
- stock := 2171950.0
- if currenttime >= timestamp(2010, 04, 01, 00, 00)
- stock := 2421500.0
- if currenttime >= timestamp(2010, 05, 01, 00, 00)
- stock := 2700300.0
- if currenttime >= timestamp(2010, 06, 01, 00, 00)
- stock := 2960600.0
- if currenttime >= timestamp(2010, 07, 01, 00, 00)
- stock := 3204950.0
- if currenttime >= timestamp(2010, 08, 01, 00, 00)
- stock := 3592950.0
- if currenttime >= timestamp(2010, 09, 01, 00, 00)
- stock := 3879000.0
- if currenttime >= timestamp(2010, 10, 01, 00, 00)
- stock := 4155850.0
- if currenttime >= timestamp(2010, 11, 01, 00, 00)
- stock := 4470050.0
- if currenttime >= timestamp(2010, 12, 01, 00, 00)
- stock := 4766150.0
- if currenttime >= timestamp(2011, 01, 01, 00, 00)
- stock := 5036250.0
- if currenttime >= timestamp(2011, 02, 01, 00, 00)
- stock := 5284950.0
- if currenttime >= timestamp(2011, 03, 01, 00, 00)
- stock := 5579500.0
- if currenttime >= timestamp(2011, 04, 01, 00, 00)
- stock := 5817950.0
- if currenttime >= timestamp(2011, 05, 01, 00, 00)
- stock := 6072750.0
- if currenttime >= timestamp(2011, 06, 01, 00, 00)
- stock := 6400250.0
- if currenttime >= timestamp(2011, 07, 01, 00, 00)
- stock := 6712700.0
- if currenttime >= timestamp(2011, 08, 01, 00, 00)
- stock := 6973900.0
- if currenttime >= timestamp(2011, 09, 01, 00, 00)
- stock := 7183350.0
- if currenttime >= timestamp(2011, 10, 01, 00, 00)
- stock := 7390150.0
- if currenttime >= timestamp(2011, 11, 01, 00, 00)
- stock := 7571700.0
- if currenttime >= timestamp(2011, 12, 01, 00, 00)
- stock := 7779500.0
- if currenttime >= timestamp(2012, 01, 01, 00, 00)
- stock := 8023200.0
- if currenttime >= timestamp(2012, 02, 01, 00, 00)
- stock := 8252250.0
- if currenttime >= timestamp(2012, 03, 01, 00, 00)
- stock := 8475500.0
- if currenttime >= timestamp(2012, 04, 01, 00, 00)
- stock := 8701850.0
- if currenttime >= timestamp(2012, 05, 01, 00, 00)
- stock := 8914700.0
- if currenttime >= timestamp(2012, 06, 01, 00, 00)
- stock := 9127350.0
- if currenttime >= timestamp(2012, 07, 01, 00, 00)
- stock := 9353500.0
- if currenttime >= timestamp(2012, 08, 01, 00, 00)
- stock := 9608550.0
- if currenttime >= timestamp(2012, 09, 01, 00, 00)
- stock := 9844750.0
- if currenttime >= timestamp(2012, 10, 01, 00, 00)
- stock := 10077650.0
- if currenttime >= timestamp(2012, 11, 01, 00, 00)
- stock := 10300950.0
- if currenttime >= timestamp(2012, 12, 01, 00, 00)
- stock := 10511875.0
- if currenttime >= timestamp(2013, 01, 01, 00, 00)
- stock := 10625175.0
- if currenttime >= timestamp(2013, 02, 01, 00, 00)
- stock := 10731825.0
- if currenttime >= timestamp(2013, 03, 01, 00, 00)
- stock := 10844500.0
- if currenttime >= timestamp(2013, 04, 01, 00, 00)
- stock := 10988125.0
- if currenttime >= timestamp(2013, 05, 01, 00, 00)
- stock := 11109275.0
- if currenttime >= timestamp(2013, 06, 01, 00, 00)
- stock := 11232900.0
- if currenttime >= timestamp(2013, 07, 01, 00, 00)
- stock := 11360900.0
- if currenttime >= timestamp(2013, 08, 01, 00, 00)
- stock := 11491500.0
- if currenttime >= timestamp(2013, 09, 01, 00, 00)
- stock := 11648650.0
- if currenttime >= timestamp(2013, 10, 01, 00, 00)
- stock := 11788075.0
- if currenttime >= timestamp(2013, 11, 01, 00, 00)
- stock := 11938750.0
- if currenttime >= timestamp(2013, 12, 01, 00, 00)
- stock := 12067325.0
- if currenttime >= timestamp(2014, 01, 01, 00, 00)
- stock := 12203800.0
- if currenttime >= timestamp(2014, 02, 01, 00, 00)
- stock := 12349750.0
- if currenttime >= timestamp(2014, 03, 01, 00, 00)
- stock := 12465700.0
- if currenttime >= timestamp(2014, 04, 01, 00, 00)
- stock := 12590300.0
- if currenttime >= timestamp(2014, 05, 01, 00, 00)
- stock := 12716150.0
- if currenttime >= timestamp(2014, 06, 01, 00, 00)
- stock := 12851450.0
- if currenttime >= timestamp(2014, 07, 01, 00, 00)
- stock := 12976150.0
- if currenttime >= timestamp(2014, 08, 01, 00, 00)
- stock := 13092275.0
- if currenttime >= timestamp(2014, 09, 01, 00, 00)
- stock := 13215900.0
- if currenttime >= timestamp(2014, 10, 01, 00, 00)
- stock := 13334625.0
- if currenttime >= timestamp(2014, 11, 01, 00, 00)
- stock := 13459400.0
- if currenttime >= timestamp(2014, 12, 01, 00, 00)
- stock := 13568225.0
- if currenttime >= timestamp(2015, 01, 01, 00, 00)
- stock := 13678725.0
- if currenttime >= timestamp(2015, 02, 01, 00, 00)
- stock := 13787950.0
- if currenttime >= timestamp(2015, 03, 01, 00, 00)
- stock := 13900600.0
- if currenttime >= timestamp(2015, 04, 01, 00, 00)
- stock := 14010350.0
- if currenttime >= timestamp(2015, 05, 01, 00, 00)
- stock := 14116950.0
- if currenttime >= timestamp(2015, 06, 01, 00, 00)
- stock := 14224400.0
- if currenttime >= timestamp(2015, 07, 01, 00, 00)
- stock := 14334175.0
- if currenttime >= timestamp(2015, 08, 01, 00, 00)
- stock := 14456700.0
- if currenttime >= timestamp(2015, 09, 01, 00, 00)
- stock := 14567625.0
- if currenttime >= timestamp(2015, 10, 01, 00, 00)
- stock := 14678775.0
- if currenttime >= timestamp(2015, 11, 01, 00, 00)
- stock := 14789625.0
- if currenttime >= timestamp(2015, 12, 01, 00, 00)
- stock := 14906475.0
- if currenttime >= timestamp(2016, 01, 01, 00, 00)
- stock := 15039125.0
- if currenttime >= timestamp(2016, 02, 01, 00, 00)
- stock := 15158450.0
- if currenttime >= timestamp(2016, 03, 01, 00, 00)
- stock := 15274725.0
- if currenttime >= timestamp(2016, 04, 01, 00, 00)
- stock := 15385750.0
- if currenttime >= timestamp(2016, 05, 01, 00, 00)
- stock := 15498725.0
- if currenttime >= timestamp(2016, 06, 01, 00, 00)
- stock := 15610000.0
- if currenttime >= timestamp(2016, 07, 01, 00, 00)
- stock := 15721925.0
- if currenttime >= timestamp(2016, 08, 01, 00, 00)
- stock := 15794500.0
- if currenttime >= timestamp(2016, 09, 01, 00, 00)
- stock := 15850362.5
- if currenttime >= timestamp(2016, 10, 01, 00, 00)
- stock := 15907262.5
- if currenttime >= timestamp(2016, 11, 01, 00, 00)
- stock := 15962137.5
- if currenttime >= timestamp(2016, 12, 01, 00, 00)
- stock := 16018575.0
- if currenttime >= timestamp(2017, 01, 01, 00, 00)
- stock := 16081387.5
- if currenttime >= timestamp(2017, 02, 01, 00, 00)
- stock := 16141162.5
- if currenttime >= timestamp(2017, 03, 01, 00, 00)
- stock := 16191787.5
- if currenttime >= timestamp(2017, 04, 01, 00, 00)
- stock := 16253712.5
- if currenttime >= timestamp(2017, 05, 01, 00, 00)
- stock := 16308862.5
- if currenttime >= timestamp(2017, 06, 01, 00, 00)
- stock := 16367962.5
- if currenttime >= timestamp(2017, 07, 01, 00, 00)
- stock := 16424300.0
- if currenttime >= timestamp(2017, 08, 01, 00, 00)
- stock := 16482837.5
- if currenttime >= timestamp(2017, 09, 01, 00, 00)
- stock := 16542200.0
- if currenttime >= timestamp(2017, 10, 01, 00, 00)
- stock := 16602525.0
- if currenttime >= timestamp(2017, 11, 01, 00, 00)
- stock := 16660787.5
- if currenttime >= timestamp(2017, 12, 01, 00, 00)
- stock := 16715937.5
- if currenttime >= timestamp(2018, 01, 01, 00, 00)
- stock := 16776450.0
- if currenttime >= timestamp(2018, 02, 01, 00, 00)
- stock := 16843762.5
- if currenttime >= timestamp(2018, 03, 01, 00, 00)
- stock := 16896312.5
- if currenttime >= timestamp(2018, 04, 01, 00, 00)
- stock := 16952512.5
- if currenttime >= timestamp(2018, 05, 01, 00, 00)
- stock := 17010087.5
- if currenttime >= timestamp(2018, 06, 01, 00, 00)
- stock := 17073087.5
- if currenttime >= timestamp(2018, 07, 01, 00, 00)
- stock := 17129625.0
- if currenttime >= timestamp(2018, 08, 01, 00, 00)
- stock := 17186437.5
- if currenttime >= timestamp(2018, 09, 01, 00, 00)
- stock := 17244587.5
- if currenttime >= timestamp(2018, 10, 01, 00, 00)
- stock := 17299912.5
- if currenttime >= timestamp(2018, 11, 01, 00, 00)
- stock := 17358400.0
- if currenttime >= timestamp(2018, 12, 01, 00, 00)
- stock := 17405450.0
- if currenttime >= timestamp(2019, 01, 01, 00, 00)
- stock := 17459487.5
- if currenttime >= timestamp(2019, 02, 01, 00, 00)
- stock := 17514275.0
- if currenttime >= timestamp(2019, 03, 01, 00, 00)
- stock := 17569362.5
- if currenttime >= timestamp(2019, 04, 01, 00, 00)
- stock := 17624400.0
- if currenttime >= timestamp(2019, 05, 01, 00, 00)
- stock := 17679400.0
- if currenttime >= timestamp(2019, 06, 01, 00, 00)
- stock := 17735862.5
- if currenttime >= timestamp(2019, 07, 01, 00, 00)
- stock := 17792250.0
- if currenttime >= timestamp(2019, 08, 01, 00, 00)
- stock := 17856137.5
- if currenttime >= timestamp(2019, 09, 01, 00, 00)
- stock := 17912187.5
- last_stock_data_time = timestamp(2019, 10, 01, 00, 00)
- if currenttime > last_stock_data_time
- stock := 17968263.0
- // Now get the higher boundary of the stock for interpolation (just for a smooth curve)
- // ...and thanks so much to Pine Script to not support arrays. All this code should be just an easy table...
- stock_h = 17968263.0
- if currenttime <= timestamp(2019, 10, 01, 00, 00)
- stock_h := 17968263.0
- if currenttime <= timestamp(2019, 09, 01, 00, 00)
- stock_h := 17912187.5
- if currenttime <= timestamp(2019, 08, 01, 00, 00)
- stock_h := 17856137.5
- if currenttime <= timestamp(2019, 07, 01, 00, 00)
- stock_h := 17792250
- if currenttime <= timestamp(2019, 06, 01, 00, 00)
- stock_h := 17735862.5
- if currenttime <= timestamp(2019, 05, 01, 00, 00)
- stock_h := 17679400
- if currenttime <= timestamp(2019, 04, 01, 00, 00)
- stock_h := 17624400
- if currenttime <= timestamp(2019, 03, 01, 00, 00)
- stock_h := 17569362.5
- if currenttime <= timestamp(2019, 02, 01, 00, 00)
- stock_h := 17514275
- if currenttime <= timestamp(2019, 01, 01, 00, 00)
- stock_h := 17459487.5
- if currenttime <= timestamp(2018, 12, 01, 00, 00)
- stock_h := 17405450
- if currenttime <= timestamp(2018, 11, 01, 00, 00)
- stock_h := 17358400
- if currenttime <= timestamp(2018, 10, 01, 00, 00)
- stock_h := 17299912.5
- if currenttime <= timestamp(2018, 09, 01, 00, 00)
- stock_h := 17244587.5
- if currenttime <= timestamp(2018, 08, 01, 00, 00)
- stock_h := 17186437.5
- if currenttime <= timestamp(2018, 07, 01, 00, 00)
- stock_h := 17129625
- if currenttime <= timestamp(2018, 06, 01, 00, 00)
- stock_h := 17073087.5
- if currenttime <= timestamp(2018, 05, 01, 00, 00)
- stock_h := 17010087.5
- if currenttime <= timestamp(2018, 04, 01, 00, 00)
- stock_h := 16952512.5
- if currenttime <= timestamp(2018, 03, 01, 00, 00)
- stock_h := 16896312.5
- if currenttime <= timestamp(2018, 02, 01, 00, 00)
- stock_h := 16843762.5
- if currenttime <= timestamp(2018, 01, 01, 00, 00)
- stock_h := 16776450
- if currenttime <= timestamp(2017, 12, 01, 00, 00)
- stock_h := 16715937.5
- if currenttime <= timestamp(2017, 11, 01, 00, 00)
- stock_h := 16660787.5
- if currenttime <= timestamp(2017, 10, 01, 00, 00)
- stock_h := 16602525
- if currenttime <= timestamp(2017, 09, 01, 00, 00)
- stock_h := 16542200
- if currenttime <= timestamp(2017, 08, 01, 00, 00)
- stock_h := 16482837.5
- if currenttime <= timestamp(2017, 07, 01, 00, 00)
- stock_h := 16424300
- if currenttime <= timestamp(2017, 06, 01, 00, 00)
- stock_h := 16367962.5
- if currenttime <= timestamp(2017, 05, 01, 00, 00)
- stock_h := 16308862.5
- if currenttime <= timestamp(2017, 04, 01, 00, 00)
- stock_h := 16253712.5
- if currenttime <= timestamp(2017, 03, 01, 00, 00)
- stock_h := 16191787.5
- if currenttime <= timestamp(2017, 02, 01, 00, 00)
- stock_h := 16141162.5
- if currenttime <= timestamp(2017, 01, 01, 00, 00)
- stock_h := 16081387.5
- if currenttime <= timestamp(2016, 12, 01, 00, 00)
- stock_h := 16018575
- if currenttime <= timestamp(2016, 11, 01, 00, 00)
- stock_h := 15962137.5
- if currenttime <= timestamp(2016, 10, 01, 00, 00)
- stock_h := 15907262.5
- if currenttime <= timestamp(2016, 09, 01, 00, 00)
- stock_h := 15850362.5
- if currenttime <= timestamp(2016, 08, 01, 00, 00)
- stock_h := 15794500
- if currenttime <= timestamp(2016, 07, 01, 00, 00)
- stock_h := 15721925
- if currenttime <= timestamp(2016, 06, 01, 00, 00)
- stock_h := 15610000
- if currenttime <= timestamp(2016, 05, 01, 00, 00)
- stock_h := 15498725
- if currenttime <= timestamp(2016, 04, 01, 00, 00)
- stock_h := 15385750
- if currenttime <= timestamp(2016, 03, 01, 00, 00)
- stock_h := 15274725
- if currenttime <= timestamp(2016, 02, 01, 00, 00)
- stock_h := 15158450
- if currenttime <= timestamp(2016, 01, 01, 00, 00)
- stock_h := 15039125
- if currenttime <= timestamp(2015, 12, 01, 00, 00)
- stock_h := 14906475
- if currenttime <= timestamp(2015, 11, 01, 00, 00)
- stock_h := 14789625
- if currenttime <= timestamp(2015, 10, 01, 00, 00)
- stock_h := 14678775
- if currenttime <= timestamp(2015, 09, 01, 00, 00)
- stock_h := 14567625
- if currenttime <= timestamp(2015, 08, 01, 00, 00)
- stock_h := 14456700
- if currenttime <= timestamp(2015, 07, 01, 00, 00)
- stock_h := 14334175
- if currenttime <= timestamp(2015, 06, 01, 00, 00)
- stock_h := 14224400
- if currenttime <= timestamp(2015, 05, 01, 00, 00)
- stock_h := 14116950
- if currenttime <= timestamp(2015, 04, 01, 00, 00)
- stock_h := 14010350
- if currenttime <= timestamp(2015, 03, 01, 00, 00)
- stock_h := 13900600
- if currenttime <= timestamp(2015, 02, 01, 00, 00)
- stock_h := 13787950
- if currenttime <= timestamp(2015, 01, 01, 00, 00)
- stock_h := 13678725
- if currenttime <= timestamp(2014, 12, 01, 00, 00)
- stock_h := 13568225
- if currenttime <= timestamp(2014, 11, 01, 00, 00)
- stock_h := 13459400
- if currenttime <= timestamp(2014, 10, 01, 00, 00)
- stock_h := 13334625
- if currenttime <= timestamp(2014, 09, 01, 00, 00)
- stock_h := 13215900
- if currenttime <= timestamp(2014, 08, 01, 00, 00)
- stock_h := 13092275
- if currenttime <= timestamp(2014, 07, 01, 00, 00)
- stock_h := 12976150
- if currenttime <= timestamp(2014, 06, 01, 00, 00)
- stock_h := 12851450
- if currenttime <= timestamp(2014, 05, 01, 00, 00)
- stock_h := 12716150
- if currenttime <= timestamp(2014, 04, 01, 00, 00)
- stock_h := 12590300
- if currenttime <= timestamp(2014, 03, 01, 00, 00)
- stock_h := 12465700
- if currenttime <= timestamp(2014, 02, 01, 00, 00)
- stock_h := 12349750
- if currenttime <= timestamp(2014, 01, 01, 00, 00)
- stock_h := 12203800
- if currenttime <= timestamp(2013, 12, 01, 00, 00)
- stock_h := 12067325
- if currenttime <= timestamp(2013, 11, 01, 00, 00)
- stock_h := 11938750
- if currenttime <= timestamp(2013, 10, 01, 00, 00)
- stock_h := 11788075
- if currenttime <= timestamp(2013, 09, 01, 00, 00)
- stock_h := 11648650
- if currenttime <= timestamp(2013, 08, 01, 00, 00)
- stock_h := 11491500
- if currenttime <= timestamp(2013, 07, 01, 00, 00)
- stock_h := 11360900
- if currenttime <= timestamp(2013, 06, 01, 00, 00)
- stock_h := 11232900
- if currenttime <= timestamp(2013, 05, 01, 00, 00)
- stock_h := 11109275
- if currenttime <= timestamp(2013, 04, 01, 00, 00)
- stock_h := 10988125
- if currenttime <= timestamp(2013, 03, 01, 00, 00)
- stock_h := 10844500
- if currenttime <= timestamp(2013, 02, 01, 00, 00)
- stock_h := 10731825
- if currenttime <= timestamp(2013, 01, 01, 00, 00)
- stock_h := 10625175
- if currenttime <= timestamp(2012, 12, 01, 00, 00)
- stock_h := 10511875
- if currenttime <= timestamp(2012, 11, 01, 00, 00)
- stock_h := 10300950
- if currenttime <= timestamp(2012, 10, 01, 00, 00)
- stock_h := 10077650
- if currenttime <= timestamp(2012, 09, 01, 00, 00)
- stock_h := 9844750
- if currenttime <= timestamp(2012, 08, 01, 00, 00)
- stock_h := 9608550
- if currenttime <= timestamp(2012, 07, 01, 00, 00)
- stock_h := 9353500
- if currenttime <= timestamp(2012, 06, 01, 00, 00)
- stock_h := 9127350
- if currenttime <= timestamp(2012, 05, 01, 00, 00)
- stock_h := 8914700
- if currenttime <= timestamp(2012, 04, 01, 00, 00)
- stock_h := 8701850
- if currenttime <= timestamp(2012, 03, 01, 00, 00)
- stock_h := 8475500
- if currenttime <= timestamp(2012, 02, 01, 00, 00)
- stock_h := 8252250
- if currenttime <= timestamp(2012, 01, 01, 00, 00)
- stock_h := 8023200
- if currenttime <= timestamp(2011, 12, 01, 00, 00)
- stock_h := 7779500
- if currenttime <= timestamp(2011, 11, 01, 00, 00)
- stock_h := 7571700
- if currenttime <= timestamp(2011, 10, 01, 00, 00)
- stock_h := 7390150
- if currenttime <= timestamp(2011, 09, 01, 00, 00)
- stock_h := 7183350
- if currenttime <= timestamp(2011, 08, 01, 00, 00)
- stock_h := 6973900
- if currenttime <= timestamp(2011, 07, 01, 00, 00)
- stock_h := 6712700
- if currenttime <= timestamp(2011, 06, 01, 00, 00)
- stock_h := 6400250
- if currenttime <= timestamp(2011, 05, 01, 00, 00)
- stock_h := 6072750
- if currenttime <= timestamp(2011, 04, 01, 00, 00)
- stock_h := 5817950
- if currenttime <= timestamp(2011, 03, 01, 00, 00)
- stock_h := 5579500
- if currenttime <= timestamp(2011, 02, 01, 00, 00)
- stock_h := 5284950
- if currenttime <= timestamp(2011, 01, 01, 00, 00)
- stock_h := 5036250
- if currenttime <= timestamp(2010, 12, 01, 00, 00)
- stock_h := 4766150
- if currenttime <= timestamp(2010, 11, 01, 00, 00)
- stock_h := 4470050
- if currenttime <= timestamp(2010, 10, 01, 00, 00)
- stock_h := 4155850
- if currenttime <= timestamp(2010, 09, 01, 00, 00)
- stock_h := 3879000
- if currenttime <= timestamp(2010, 08, 01, 00, 00)
- stock_h := 3592950
- if currenttime <= timestamp(2010, 07, 01, 00, 00)
- stock_h := 3204950
- if currenttime <= timestamp(2010, 06, 01, 00, 00)
- stock_h := 2960600
- if currenttime <= timestamp(2010, 05, 01, 00, 00)
- stock_h := 2700300
- if currenttime <= timestamp(2010, 04, 01, 00, 00)
- stock_h := 2421500
- if currenttime <= timestamp(2010, 03, 01, 00, 00)
- stock_h := 2171950
- if currenttime <= timestamp(2010, 02, 01, 00, 00)
- stock_h := 1901200
- if currenttime <= timestamp(2010, 01, 01, 00, 00)
- stock_h := 1629350
- if currenttime <= timestamp(2009, 12, 01, 00, 00)
- stock_h := 1429450
- if currenttime <= timestamp(2009, 11, 01, 00, 00)
- stock_h := 1313750
- if currenttime <= timestamp(2009, 10, 01, 00, 00)
- stock_h := 1214700
- if currenttime <= timestamp(2009, 09, 01, 00, 00)
- stock_h := 1106550
- if currenttime <= timestamp(2009, 08, 01, 00, 00)
- stock_h := 1019550
- if currenttime <= timestamp(2009, 07, 01, 00, 00)
- stock_h := 929300
- if currenttime <= timestamp(2009, 06, 01, 00, 00)
- stock_h := 818500
- if currenttime <= timestamp(2009, 05, 01, 00, 00)
- stock_h := 658050
- if currenttime <= timestamp(2009, 04, 01, 00, 00)
- stock_h := 485350
- if currenttime <= timestamp(2009, 03, 01, 00, 00)
- stock_h := 300350
- if currenttime <= timestamp(2009, 02, 01, 00, 00)
- stock_h := 137700
- if currenttime <= timestamp(2009, 01, 01, 00, 00)
- stock_h := 50
- interpolation = dayofmonth/30.5 // approximation
- stock := stock_h*interpolation+stock*(1-interpolation)
- // Calculate current halving
- // Get past halving from historical data, and approximate flow from past data
- halving = 0.0
- yearly_flow = 0.0
- yearly_flow := 10500000.0/((timestamp(2012, 11, 28, 00, 00)-timestamp(2009, 01, 03, 00, 00))/((1000*3600*24*365.25)))
- if currenttime > timestamp(2012, 11, 28, 00, 00)
- halving := halving + 1
- yearly_flow := 5250000.0/((timestamp(2016, 07, 09, 00, 00)-timestamp(2012, 11, 28, 00, 00))/((1000*3600*24*365.25)))
- if currenttime > timestamp(2016, 07, 09, 00, 00)
- halving := halving + 1
- yearly_flow := (17968263.0-15750000)/((timestamp(2019, 10, 01, 00, 00)-timestamp(2016, 07, 09, 00, 00))/((1000*3600*24*365.25)))
- last_halving_data_time = timestamp(2020, 05, 5, 00, 00) // Estimate
- if currenttime > last_halving_data_time
- // Number of days since last_halving_data_time
- after_halving_day = (currenttime-last_halving_data_time)/(1000*3600*24)
- yearfloat = after_halving_day/365.25
- halving := halving + 1 + floor(yearfloat/4)
- // yearly_flow calculated below
- blockflow = 50/pow(2, halving)
- // Calculate future flow
- if currenttime > last_halving_data_time
- yearly_flow := blockflow*blockperyear
- // Future stock (after historical data)
- if currenttime > last_stock_data_time
- days_after_data = (currenttime-last_stock_data_time)/(1000*3600*24)
- stock := stock+blockperyear*(days_after_data/365.25)*blockflow
- if halving >= 4
- for i = 4 to halving
- stock := stock+blockperhalving*50/pow(2, i-1)
- SF = stock/yearly_flow
- outSF = exp(-1.84) * pow(SF, 3.36)
- //outSF := ((timestamp(2012, 11, 28, 00, 00)-timestamp(2009, 01, 03, 00, 00))/((1000*3600*24*365.25))) // Debug
- [outtop, outfit, outbottom, outSF, outnlbp]
- // Finally plot for real
- [outtop, outfit, outbottom, outSF, outnlbp] = calculate_series(time("D"), 0)
- plottop = plot(showtop ? outtop:na, color=color.red, title="Power Law Top")
- plotfit = plot(showfit ? outfit:na, color=color.gray, title="Power Law Regression Fit")
- plotbottom = plot(showbottom ? outbottom:na, color=color.green, title="Power Law Bottom")
- fill(plottop, plotfit, color=color.red, transp=90, title="Upper Fill")
- fill(plotfit, plotbottom, color=color.green, transp=90, title="Lower Fill")
- plot(showSF ? outSF:na, title="Bitcoin Stock to Flow", color=color.blue, linewidth=2)
- plot(shownlbp ? outnlbp:na, color=color.yellow, title="Never Look Back")
- //if timeframe.period == '60'
- //'D' - daily, 'W' - weekly, 'M' - monthly, '5D' - 5 days, '12M' - one year, '3M' - one quarter
- [outtop2, outfit2, outbottom2, outSF2, outnlbp2] = calculate_series(time("D"), 1000*3600*24*208*7)
- plot(showtop ? outtop2:na, color=color.red, title="Power Law Top", offset=208)
- plot(showfit ? outfit2:na, color=color.gray, title="Power Law Regression Fit", offset=208)
- plot(showbottom ? outbottom2:na, color=color.green, title="Power Law Bottom", offset=208)
- plot(showSF ? outSF2:na, title="Bitcoin Stock to Flow", color=color.blue, linewidth=2, offset=208)
- plot(shownlbp ? outnlbp2:na, color=color.yellow, title="Never Look Back", offset=208)
- [outtop3, outfit3, outbottom3, outSF3, outnlbp3] = calculate_series(time("D"), 1000*3600*24*208*7*2)
- plot(showtop ? outtop3:na, color=color.red, title="Power Law Top", offset=208*2)
- plot(showfit ? outfit3:na, color=color.gray, title="Power Law Regression Fit", offset=208*2)
- plot(showbottom ? outbottom3:na, color=color.green, title="Power Law Bottom", offset=208*2)
- plot(showSF ? outSF3:na, title="Bitcoin Stock to Flow", color=color.blue, linewidth=2, offset=208*2)
- plot(shownlbp ? outnlbp3:na, color=color.yellow, title="Never Look Back", offset=208*2)
- //[outtop4, outfit4, outbottom4, outSF4] = calculate_series(time("D"), 1000*3600*24*208*7*3)
- //plot(showtop ? outtop4:na, color=color.red, title="Power Law Top", offset=208*3)
- //plot(showfit ? outfit4:na, color=color.gray, title="Power Law Regression Fit", offset=208*3)
- //plot(showbottom ? outbottom4:na, color=color.green, title="Power Law Bottom", offset=208*3)
- //plot(showSF ? outSF4:na, title="Bitcoin Stock to Flow", color=color.blue, linewidth=2, offset=208*3)
- //[outtop5, outfit5, outbottom5, outSF5] = calculate_series(time("D"), 1000*3600*24*208*7*4)
- //plot(showtop ? outtop5:na, color=color.red, title="Power Law Top", offset=208*4)
- //plot(showfit ? outfit5:na, color=color.gray, title="Power Law Regression Fit", offset=208*4)
- //plot(showbottom ? outbottom5:na, color=color.green, title="Power Law Bottom", offset=208*4)
- //plot(showSF ? outSF5:na, title="Bitcoin Stock to Flow", color=color.blue, linewidth=2, offset=208*4)
- //[outtop6, outfit6, outbottom6, outSF6] = calculate_series(time("D"), 1000*3600*24*208*7*5)
- //plot(showtop ? outtop6:na, color=color.red, title="Power Law Top", offset=208*5)
- //plot(showfit ? outfit6:na, color=color.gray, title="Power Law Regression Fit", offset=208*5)
- //plot(showbottom ? outbottom6:na, color=color.green, title="Power Law Bottom", offset=208*5)
- //plot(showSF ? outSF6:na, title="Bitcoin Stock to Flow", color=color.blue, linewidth=2, offset=208*5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement