Last active
February 20, 2021 23:47
-
-
Save jamesray1/420e9268201fb5cd94d2437b9f1a4184 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@version=4 | |
// | |
// @author James Ray [jcray] | |
// Market cap bands for Uniswap. Modified from Top Cap for BTC by aamonkey. | |
// Use only with the YTD timeframe. | |
// See also my other scripts: | |
// Medium article linking to all of the below: https://james-christopher-ray.medium.com/market-cap-scripts-for-cryptocurrencies-on-trad-30825ec1d5c8 | |
// - 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: http://bit.ly/unicapb | |
// - For Decentr: http://bit.ly/decentrcap | |
// | |
study("Uniswap UNI Top Cap, Mid Cap and Bottom/Average Cap / Market Cap Bands [jcray]",shorttitle="UNI Cap Bands [jr]", overlay=true) | |
//input | |
mulTop = input(4.5, 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(09, title = "Launch Month") | |
launchDay = input(18, 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