OPEN-SOURCE SCRIPT

SPY EMA + VWAP Day Trading Strategy (Market Hours Only)

50
//version=5
indicator("SPY EMA + VWAP Day Trading Strategy (Market Hours Only)", overlay=true)

// === Market Hours Filter (EST / New York Time) ===
nySession = input.session("0930-1600", "Market Session (NY Time)")
inSession = time(timeframe.period, "America/New_York") >= time(nySession, "America/New_York")

// EMAs
ema9 = ta.ema(close, 9)
ema21 = ta.ema(close, 21)

// VWAP
vwap = ta.vwap(close)

// Plot EMAs & VWAP
plot(ema9, "EMA 9", color=color.green, linewidth=2)
plot(ema21, "EMA 21", color=color.orange, linewidth=2)
plot(vwap, "VWAP", color=color.blue, linewidth=2)

// ----------- Signals -----------
long_raw = close > ema9 and ema9 > ema21 and close > vwap and ta.crossover(ema9, ema21)
short_raw = close < ema9 and ema9 < ema21 and close < vwap and ta.crossunder(ema9, ema21)

// Apply Market Hours Filter
long_signal = long_raw and inSession
short_signal = short_raw and inSession

// Plot Signals
plotshape(long_signal,
title="BUY",
style=shape.labelup,
location=location.belowbar,
color=color.green,
size=size.small,
text="BUY")

plotshape(short_signal,
title="SELL",
style=shape.labeldown,
location=location.abovebar,
color=color.red,
size=size.small,
text="SELL")

// Alerts
alertcondition(long_signal, title="BUY Alert", message="BUY Signal (Market Hours Only)")
alertcondition(short_signal, title="SELL Alert", message="SELL Signal (Market Hours Only)")

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como asesoramiento o recomendaciones financieras, de inversión, de trading o de otro tipo proporcionadas o respaldadas por TradingView. Más información en Condiciones de uso.