Bandas de Bollinger + 3 Medias Moviles Simples
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jeanjara77

//@version=5
indicator(shorttitle="BB+3MA", title="Bollinger Bands + Medias Moviles Simples", overlay=true, timeframe="", timeframe_gaps=true)
length = input.int(20, minval=1)
src = input(close, title="Source")
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
basis = ta.sma(src, length)
dev = mult * ta.stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input.int(0, "Offset", minval = -500, maxval = 500)
plot(basis, "Basis", color=#2962FF, offset = offset)
p1 = plot(upper, "Upper", color=#bbbdc2, offset = offset)
p2 = plot(lower, "Lower", color=#bbbdc2, offset = offset)
fill(p1, p2, title = "Background", color=color.rgb(76, 169, 245, 96))

//Evaluation
Bear = high >= upper
Bull = low <= lower 

//Plots
plotshape(Bear, style=shape.triangledown, location=location.abovebar, 
     color=color.rgb(255, 82, 82, 66), size=size.tiny)
plotshape(Bull, style=shape.triangleup, location=location.belowbar, 
     color=color.rgb(76, 175, 79, 64), size=size.tiny)
 
// Alert Functionality
alertcondition(Bear or Bull, title="Any Signal", message="{{exchange}}:{{ticker}}" + " {{interval}}")
alertcondition(Bear, title="Bearish Signal", message="{{exchange}}:{{ticker}}" + " {{interval}}")
alertcondition(Bull, title="Bullish Signal", message="{{exchange}}:{{ticker}}" + " {{interval}}")

//3SMA
plot(ta.sma(close, 200), color=#f00808, title="SMA200")
plot(ta.sma(close, 100), color=color.rgb(238, 215, 4), title="SMA100")
plot(ta.sma(close, 50), color=#099b2d, title="SMA50")
