Skip to content

Instantly share code, notes, and snippets.

@badjano
Last active February 19, 2020 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badjano/c4e44d7f2f50b285ce01f1b447c7451b to your computer and use it in GitHub Desktop.
Save badjano/c4e44d7f2f50b285ce01f1b447c7451b to your computer and use it in GitHub Desktop.
// © Badjano 2019
// please donate BTC: 1BADjanox8xaNUYTQgHcXw6mmwuSsE9ZSg
//@version=4
study("BTC Bottom and Top", overlay=true)
float t = (time*0.001-1100000000) * 0.000000001
t1 = plot(pow(t * 5 ,10.0), color=color.green)
t2 = plot(pow(t * 5.65 ,9.0), color=color.green)
t3 = plot(pow(t * 7.75 ,8), color=color.red)
t4 = plot(pow(t * 9 ,7.5), color=color.red)
fill(t1, t2, color=color.green, transp=90)
fill(t3, t4, color=color.red, transp=90)
chartResolution = timeframe.multiplier
if timeframe.isdaily
chartResolution := 24*60*timeframe.multiplier
if timeframe.isweekly
chartResolution := 24*60*7*timeframe.multiplier
if timeframe.ismonthly
chartResolution := 24*60*30*timeframe.multiplier
stfscale = (24*60)/chartResolution
pstf = ceil(input(defval=10, title="Stock to Flow period", type=input.integer)*stfscale)
stock = security("QUANDL:BCHAIN/TOTBC", "D", close)
flow = (stock - stock[pstf])*10000/pstf * stfscale
model = pow(sma(stock/flow,pstf), 3.5)*10000
plot(model, title="Bitcoin Stock to Flow Model", color=close > model ? color.red : color.green, linewidth=2, transp=50)
// please donate BTC: 1BADjanox8xaNUYTQgHcXw6mmwuSsE9ZSg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment