OPEN-SOURCE SCRIPT

MNQ Pro Scalping | SMA20 + VWAP Color

182
//version=5
TIFFANY//version=5
indicator("MNQ Pro Scalping | SMA20 + VWAP Color + ATR SLTP + Fake Breakout", overlay=true)

// ===== INPUTS =====
smaLen = input.int(20, "SMA Length")
atrLen = input.int(14, "ATR Length")
slMult = input.float(1.0, "SL = ATR x", step=0.1)
tpMult = input.float(1.5, "TP = ATR x", step=0.1)
showNY = input.bool(true, "Only New York Session (09:30–16:00 ET)")

// ===== NY SESSION FILTER =====
inNY = not showNY or time(timeframe.period, "0930-1600")

// ===== SMA 20 =====
sma20 = ta.sma(close, smaLen)
smaColor = close > sma20 ? color.green : color.red
plot(sma20, "SMA 20", color=smaColor, linewidth=2)

// ===== VWAP (COLOR CHANGE) =====
vwapVal = ta.vwap(hlc3)
vwapColor = close > vwapVal ? color.green : color.red
plot(vwapVal, "VWAP", color=vwapColor, linewidth=2)

// ===== ATR =====
atr = ta.atr(atrLen)

// ===== CROSS CONDITIONS =====
crossUp = ta.crossover(close, sma20)
crossDown = ta.crossunder(close, sma20)

// ===== VALID TRADE CONDITIONS =====
longCond = crossUp and close > vwapVal and inNY
shortCond = crossDown and close < vwapVal and inNY

// ===== ATR SL / TP LEVELS =====
longSL = close - atr * slMult
longTP = close + atr * tpMult

shortSL = close + atr * slMult
shortTP = close - atr * tpMult

// ===== PLOT SL / TP WHEN SIGNAL =====
plot(longCond ? longSL : na, "Long SL", color=color.red, style=plot.style_linebr)
plot(longCond ? longTP : na, "Long TP", color=color.green, style=plot.style_linebr)

plot(shortCond ? shortSL : na, "Short SL", color=color.red, style=plot.style_linebr)
plot(shortCond ? shortTP : na, "Short TP", color=color.green, style=plot.style_linebr)

// ===== FAKE BREAKOUT DETECTION =====
// Giá cắt SMA nhưng đóng nến quay ngược lại
fakeUp = ta.crossover(high, sma20) and close < sma20
fakeDown = ta.crossunder(low, sma20) and close > sma20

plotshape(fakeUp and inNY, title="Fake Up", style=shape.xcross, location=location.abovebar, color=color.red, size=size.small)
plotshape(fakeDown and inNY, title="Fake Down", style=shape.xcross, location=location.belowbar, color=color.green, size=size.small)

// ===== SIGNAL SHAPES =====
plotshape(longCond, title="LONG", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(shortCond, title="SHORT", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)

// ===== ALERTS =====
alertcondition(longCond,
title="MNQ LONG – ATR Setup",
message="MNQ LONG: Cross ABOVE SMA20 | Above VWAP | ATR SL/TP valid")

alertcondition(shortCond,
title="MNQ SHORT – ATR Setup",
message="MNQ SHORT: Cross BELOW SMA20 | Below VWAP | ATR SL/TP valid")

alertcondition(fakeUp,
title="Fake Breakout UP",
message="WARNING: Fake breakout ABOVE SMA20")

alertcondition(fakeDown,
title="Fake Breakout DOWN",
message="WARNING: Fake breakout BELOW SMA20")

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.