SPY/QQQ Early Scalper – 5 Min (Noise Reduced)

krishnan806 · study · 77 行 · 点赞 63 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("SPY/QQQ Early Scalper – 5 Min (Noise Reduced)", overlay=true, max_lines_count=500, max_boxes_count=500)
 
// === INPUTS ===
emaFastLen   = input.int(9, "Fast EMA len")
emaSlowLen   = input.int(21, "Slow EMA len")
emaUltraLen  = input.int(5, "Ultra-fast EMA len")
rsiLen       = input.int(14, "RSI len")
volLen       = input.int(20, "Volume SMA len")
slopeThresh  = input.float(0.02, "EMA slope threshold (%)") // Minimal slope relative to price
volumeMult   = input.float(1.2, "Volume multiplier")        // Only consider high volume
useHTF       = input.bool(true, "Use 15-min trend filter")
 
// === 5-MIN CANDLE DATA ===
close5  = request.security(syminfo.tickerid, "5", close)
high5   = request.security(syminfo.tickerid, "5", high)
low5    = request.security(syminfo.tickerid, "5", low)
volume5 = request.security(syminfo.tickerid, "5", volume)
 
// === INDICATORS ON 5-MIN ===
emaFast  = ta.ema(close5, emaFastLen)
emaSlow  = ta.ema(close5, emaSlowLen)
emaUltra = ta.ema(close5, emaUltraLen)
vwapVal  = ta.vwap(close5)
rsiVal   = ta.rsi(close5, rsiLen)
volSMA   = ta.sma(volume5, volLen)
 
// === EMA SLOPE ===
emaFastSlope = emaFast - emaFast[1]
minSlope = close5 * slopeThresh / 100  // minimal price movement
 
// === HIGHER TIMEFRAME FILTER (OPTIONAL) ===
emaFastHTF = useHTF ? request.security(syminfo.tickerid, "15", ta.ema(close, emaFastLen)) : na
 
// === EARLY SCALP CONDITIONS ===
callCondition = (close5 > emaUltra and
                emaFastSlope > minSlope and
                rsiVal > 55 and
                volume5 > volSMA * volumeMult)
 
putCondition  = (close5 < emaUltra and
                emaFastSlope < -minSlope and
                rsiVal < 45 and
                volume5 > volSMA * volumeMult)
 
// Apply higher timeframe trend filter
if useHTF
    callCondition := callCondition and close5 > emaFastHTF
    putCondition  := putCondition and close5 < emaFastHTF
 
// === PLOTS ===
plot(emaFast, "EMA Fast", color=color.new(color.blue, 0))
plot(emaSlow, "EMA Slow", color=color.new(color.orange, 0))
plot(emaUltra, "EMA Ultra", color=color.new(color.aqua, 0))
plot(vwapVal, "VWAP", color=color.new(color.purple, 0))
 
// === LABELS WITH COOLDOWN ===
var bool inCall = false
var bool inPut  = false
 
if callCondition and not inCall
    label.new(bar_index, low, "CALL", style=label.style_label_up, color=color.new(color.green,0), textcolor=color.white)
    inCall := true
    inPut  := false
else if not callCondition
    inCall := false
 
if putCondition and not inPut
    label.new(bar_index, high, "PUT", style=label.style_label_down, color=color.new(color.red,0), textcolor=color.white)
    inPut  := true
    inCall := false
else if not putCondition
    inPut := false
 
// === ALERTS ===
alertcondition(callCondition, title="SPY CALL", message="CALL SPY/QQQ Early Entry")
alertcondition(putCondition, title="SPY PUT", message="PUT SPY/QQQ Early Entry")

← 返回列表