Actieve Inversiones EMABBOL by EDOHEN
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Jesus_Salvatierra

//@version=5
indicator("Actieve Inversiones EMABBOL by EDOHEN",shorttitle= "EMABBOL", overlay=true)

hideSma= input.bool(defval=true,title="Show Moving Averages", group= "Moving Averages")
hideBB= input.bool(defval=false,title="Show BB", group= "Bollinger Bands")
fuente= input.source(hlc3,title= "Source", group= "Bollinger Bands")
longitud= input.int(defval=20,title= "Length", group= "Bollinger Bands")
multiplo= input.float(defval=2.0,title= "Mult", group= "Bollinger Bands")
centro = ta.sma(fuente, longitud)
dev = multiplo * ta.stdev(fuente, longitud)
upper = centro + dev
lower = centro - dev


plot(hideBB? centro:na, "BB Moving Average", color=color.new(color.black,50), style=plot.style_circles)
p1 = plot(hideBB?upper:na, "Upper Band", color=color.new(color.black,70))
p2 = plot(hideBB?lower:na, "Lower Band", color=color.new(color.black,70))
fill(p1, p2, title = "Fill", color=color.rgb(33, 150, 243, 95))


// EMA CROSS{

longitud1= input.int(9,title= "Fast Moving Average",group= "Moving Averages")
longitud2= input.int(21,title= "Medium Moving Average",group= "Moving Averages")
longitud3= input.int(50,title= "Slow Moving Average",group= "Moving Averages")
slowma= ta.ema(fuente,longitud1)
midma= ta.ema(fuente,longitud2)
fastma= ta.ema(fuente,longitud3)
// }

CrossDown = ta.crossunder(close,slowma) and ta.crossunder(close,midma) and ta.crossunder(close,fastma) and ta.rsi(close,14) <60
CrossUp   = ta.crossover(close,slowma) and ta.crossover(close,midma) and ta.crossover(close,fastma) and ta.rsi(close,14) >40

plot( hideSma? slowma:na,color=color.green,linewidth=2,title= "Slow")
plot(hideSma? midma:na,color=color.orange,linewidth=2,title= "Medium")
plot(hideSma?fastma:na,color=color.red,linewidth=2,title= "Fast")
plotshape(CrossDown? close:na, title="Cross Down",location=location.abovebar,size=size.auto,text="Sell", textcolor= color.red, color=color.red)
plotshape(CrossUp? close:na, title="Cross Up",location=location.belowbar,size=size.auto,text="Buy", textcolor= color.green, color=color.green)

alertcondition(CrossDown, "Sell")
alertcondition(CrossUp, "Buy")