OPEN-SOURCE SCRIPT

EMA Crossover with VWAP and SMA

102
//version=5
// Indicator: EMA Crossover with VWAP and SMA 200
indicator("EMA Crossover with VWAP and SMA", overlay=true)

// Definir las EMAs
ema21 = ta.ema(close, 21)
ema50 = ta.ema(close, 50)

// Definir VWAP y SMA 200
vwap_line = ta.vwap(hlc3)
sma200 = ta.sma(close, 200)

// Detectar cruces
crossOver = ta.crossover(ema21, ema50)
crossUnder = ta.crossunder(ema21, ema50)

// Plotear las líneas
plot(ema21, color=color.blue, title="EMA 21", linewidth=2)
plot(ema50, color=color.red, title="EMA 50", linewidth=2)
plot(vwap_line, color=color.purple, title="VWAP", linewidth=1)
plot(sma200, color=color.orange, title="SMA 200", linewidth=2)

// Señales de compra y venta
plotshape(crossOver, title="Compra", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(crossUnder, title="Venta", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)

// Alertas
alertcondition(crossOver, title="Señal de Compra", message="EMA 21 cruza por encima de EMA 50 - Posible Compra")
alertcondition(crossUnder, title="Señal de Venta", message="EMA 21 cruza por debajo de EMA 50 - Posible Venta")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.