Skip to content

Instantly share code, notes, and snippets.

@kebman
Created June 30, 2019 01:40
Show Gist options
  • Save kebman/4e49e58655a0888131dc04ed0863c4fe to your computer and use it in GitHub Desktop.
Save kebman/4e49e58655a0888131dc04ed0863c4fe to your computer and use it in GitHub Desktop.
The Rastani Ribbon, based on Alessio Rastani's moving averages
// See: Here's Exactly WHEN I am Buying Bitcoin. Alessio Rastani. Published on 8 Jun 2019. https://youtu.be/TiUUJxdynaY
study(title = "Rastani Ribbon", shorttitle="Rastani Ribbon", overlay=true)
src0 = close, len1 = input(21, minval=1, title="MA Length")
src1 = close, len2 = input(55, minval=1, title="MA Length")
src2 = close, len3 = input(100, minval=1, title="EMA Length")
src3 = close, len4 = input(100, minval=1, title="MA Length")
src4 = close, len0 = input(200, minval=1, title="MA Length")
sma1 = sma(src1, len1)
sma2 = sma(src2, len2)
ema3 = ema(src3, len3)
sma4 = sma(src4, len4)
ema0 = sma(src0, len0)
plot_color1 = sma1 >= sma1[2] ? blue : sma1 < sma1[2] ? blue : na
plot_color2 = sma2 >= sma2[2] ? #FF00FF : sma2 < sma2[2] ? #FF00FF : na
plot_color3 = ema3 >= ema3[2] ? #FFFF00 : ema3 < ema3[2] ? #FFFF00 : na
plot_color4 = sma4 >= sma4[2] ? red : sma4 < sma4[2] ? red : na
plot_color0 = ema0 >= ema0[2] ? red : sma4 < sma4[2] ? red : na
plot(sma1, title="MA Plot", style=line, linewidth=1, color = plot_color1)
plot(sma2, title="MA Plot", style=line, linewidth=1, color = plot_color2)
plot(ema3, title="EMA Plot", style=line, linewidth=3, color = plot_color3)
plot(sma4, title="MA Plot", style=line, linewidth=1, color = plot_color4)
plot(ema0, title="MA Plot", style=line, linewidth=3, color = plot_color0)
@kebman
Copy link
Author

kebman commented Jun 30, 2019

How to use: Mark the code. Copy it (Ctrl+C or Cmd+C). Then open a chart in TradingView, and click the Pine Editor. Then paste the code into the Pine Editor (Ctrl+V or Cmd+V), hit save and enjøy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment