Skip to content

Instantly share code, notes, and snippets.

@jamesray1
Created February 12, 2021 23:29
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/368ae8db3ba020abb6fcbab6f7950d8d to your computer and use it in GitHub Desktop.
Save jamesray1/368ae8db3ba020abb6fcbab6f7950d8d to your computer and use it in GitHub Desktop.
//@version=4
//
// @author jcray
// ETH Top, Mid and Bottom Cap Bands. Modified from Bitcoin Top/Average Cap scripts by aamonkey
//
study("ETH Top, Mid and Bottom Cap Bands [jcray]",shorttitle="ETH Cap Bands [jcr]", overlay=true)
//input
mulTop = input(12.9, title = "Top Multiplier")
mulBottom = input(0.5, title = "Average Multiplier")
mulMid = avg(mulTop,mulBottom)
launchYear = input(2015, title = "Launch Year")
launchMonth = input(07, title = "Launch Month")
launchDay = input(30, title = "Launch Day")
//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)
//Launch timestamp of the ticker's network (ETH, BTC, etc.)
launchTimestampTicker = timestamp(launchYear,launchMonth,launchDay,00,00)
secondsRawB = floor(launchTimestampTicker / 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(mod_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