Skip to content

Instantly share code, notes, and snippets.

@jamesray1
Last active February 20, 2021 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 jamesray1/29e305cabbec6591d7a9c23118fd912c to your computer and use it in GitHub Desktop.
Save jamesray1/29e305cabbec6591d7a9c23118fd912c to your computer and use it in GitHub Desktop.
//@version=4
//
// @author James Ray [jcray]
// Market cap bands for Decentr. Modified from Top Cap for BTC by aamonkey.
// Use only with the YTD timeframe.
// See also my other scripts:
//
// - Top Cap, Mid Cap and Bottom/Average Cap / market cap bands for Ethereum: bit.ly/ethcaps
// - Top Cap, Mid Cap and Bottom/Average Cap / market cap bands for Holo HOT tokens: bit.ly/hottcmc
// - Top Cap, Mid Cap and Bottom/Average Cap / market cap bands for BTC: bit.ly/BTCcaps
// - For Uniswap
// - For Decentr: http://bit.ly/decentrcap
//
study("Decentr UNI Top Cap, Mid Cap and Bottom/Average Cap / Market Cap Bands [jcray]",shorttitle="UNI Cap Bands [jr]", overlay=true)
//input
mulTop = input(7.8, title = "Top Multiplier")
// Commented out because the Bottom Cap is the moving average of the market cap.
// Could modify the script to add an extra band for the absolute minimum bottom band, but it's not worth it, IMO.
// The price may not fall below the Bottom Cap, and if it does then it is unlikely to fall much lower.
// mulBottom = input(0.5, title = "Bottom Multiplier")
// "Mining will begin on September 18th 2020 12am UTC."
// —https://uniswap.org/blog/uni/
launchYear = input(2020, title = "Launch Year")
launchMonth = input(7, title = "Launch Month")
launchDay = input(1, title = "Launch Day")
mulMid = avg(mulTop,1)
//Getting start of chart
date = valuewhen(bar_index==0, time, 0)
//Converting start of chart
secondsRaw = floor(date/ 1000)
minutesRaw = floor(secondsRaw / 60)
hoursRaw = floor(minutesRaw / 60)
daysRaw = floor(hoursRaw / 24)
//Start of ETH
startETH = timestamp(launchYear,launchMonth,launchDay,00,00)
secondsRawB = floor(startETH / 1000)
minutesRawB = floor(secondsRawB / 60)
hoursRawB = floor(minutesRawB / 60)
daysRawB = floor(hoursRawB / 24)
//Calculation
difference = daysRaw - daysRawB
bottom = cum(close)/(difference+bar_index+1)
//mod_bottom = mulBottom*bottom
mid = mulMid*bottom
top = mulTop*bottom
//Plot
plot(bottom, title="Bottom Cap", color = color.blue, linewidth = 3)
plot(mid, title="Mid Cap", color = color.yellow, linewidth = 3)
plot(top, title="Top Cap", color = color.red, linewidth = 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment