Last active
February 26, 2018 05:25
-
-
Save chronossc/1acc5e10455f236484accae40e96471c to your computer and use it in GitHub Desktop.
Ema Crosses + Bollinger Bands
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=3 | |
study(title="EMA Cross + BB", shorttitle=':', overlay=true) | |
// data = close >= open | |
// plotchar(data, char='↓', color=lime, text="Buy") | |
// plotchar(data, char='↑', location=location.belowbar, color=red, text="Sell") | |
// Bollinger Bands: Madrid : 14/SEP/2014 11:07 : 2.0 | |
// This displays the traditional Bollinger Bands, the difference is | |
// that the 1st and 2nd StdDev are outlined with two colors and two | |
// different levels, one for each Standard Deviation | |
//study(shorttitle="MBB", title="Bollinger Bands", overlay=true) | |
src = input(close, type=source) | |
length = input(34, minval=1) | |
mult = input(2.0, minval=0.001, maxval=50, type=float) | |
basis = sma(src, length) | |
dev = stdev(src, length) | |
dev2 = mult*dev | |
upper1 = basis + dev | |
lower1 = basis - dev | |
upper2 = basis + dev2 | |
lower2 = basis - dev2 | |
colorBasis = src >= basis ? #55FFFF : orange | |
pBasis = plot(basis, linewidth=2, color=colorBasis, title="BB Basis", transp=0) | |
// pUpper1 = plot(upper1, color=white, style=circles, title="BB Half Upper") | |
pUpper2 = plot(upper2, color=#1AB9B9, linewidth=2, transp=0, title="BB Upper") | |
// pLower1 = plot(lower1, color=white, style=circles, title="BB Half Lower") | |
pLower2 = plot(lower2, color=#1AB9B9, linewidth=2, transp=0, title="BB Lower") | |
fill(pBasis,pUpper2, color=colorBasis, transp=90, editable=false) | |
// fill(pUpper1, pUpper2, color=blue, transp=90, editable=false) | |
fill(pBasis,pLower2, color=colorBasis, transp=90, editable=false) | |
// fill(pLower1, pLower2, color=orange, transp=90, editable=false) | |
ema10 = ema(close, 10) | |
ema17 = ema(close, 17) | |
ema20 = ema(close, 20) | |
ema50 = ema(close, 50) | |
ema72 = ema(close, 72) | |
ema100 = ema(close, 100) | |
ema200 = ema(close, 200) | |
plot(ema10, title="EMA 10", color=#00aa7f, transp=35, linewidth=2) | |
plot(ema17, color=#FF00FF, title="EMA 17", transp=35, linewidth=2) | |
plot(ema20, title="EMA 20", color=#00aaff, transp=35, linewidth=2) | |
plot(ema50, title="EMA 50", color=#55FF00, transp=35, linewidth=2) | |
plot(ema72, color=orange, title="EMA 72", transp=35, linewidth=2) | |
plot(ema100, title="EMA 100", color=#FFC800, transp=35, linewidth=2) | |
plot(ema200, title="EMA 200", color=#0000FF, transp=35, linewidth=2) | |
// plot(cross(ema50, ema200) ? ema50 : na, style=cross, linewidth=5, editable=false) | |
plotshape(crossover(ema50, ema200) ? ema50 : na, text='EMA 50 ↑ 200', color=white, style=shape.arrowup, location=location.absolute) | |
plotshape(crossunder(ema50, ema200) ? ema50 : na, text='EMA 50 ↓ 200', color=white, style=shape.arrowdown, location=location.absolute) | |
// plot(cross(ema100, ema200) ? ema100 : na, style=cross, linewidth=5, title='Cross EMA 100/200', editable=false) | |
plotshape(crossover(ema100, ema200) ? ema100 : na, text='EMA 100 ↑ 200', color=white, style=shape.arrowup, location=location.absolute) | |
plotshape(crossunder(ema100, ema200) ? ema100 : na, text='EMA 100 ↓ 200', color=white, style=shape.arrowdown, location=location.absolute) | |
// plot(cross(ema17, ema72) ? ema17 : na, style=cross, linewidth=5, color=white, title='Cross EMA 17/72', editable=false) | |
plotshape(crossover(ema17, ema72) ? ema17 : na, text='EMA 17 ↑ 72', color=white, style=shape.arrowup, location=location.absolute) | |
plotshape(crossunder(ema17, ema72) ? ema17 : na, text='EMA 17 ↓ 72', color=white, style=shape.arrowdown, location=location.absolute) | |
// plot(cross(ema10, ema50) ? ema10 : na, style=cross, linewidth=3, title='Cross EMA 10/50', editable=false) | |
plotshape(crossover(ema10, ema50) ? ema10 : na, text='EMA 10 ↑ 50', color=white, style=shape.arrowup, location=location.absolute) | |
plotshape(crossunder(ema10, ema50) ? ema10 : na, text='EMA 10 ↓ 50', color=white, style=shape.arrowdown, location=location.absolute) | |
// plot(cross(ema20, ema50) ? ema20 : na, style=cross, linewidth=3, title='Cross EMA 20/50', editable=false) | |
plotshape(crossover(ema20, ema50) ? ema20 : na, text='EMA 20 ↑ 50', color=white, style=shape.arrowup, location=location.absolute) | |
plotshape(crossunder(ema20, ema50) ? ema20 : na, text='EMA 20 ↓ 50', color=white, style=shape.arrowdown, location=location.absolute) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment