OPEN-SOURCE SCRIPT
SPY EMA + VWAP Day Trading Strategy (Market Hours Only)

//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)")
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)")
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.