//@version=6
// NQ Nasdaq-100 — VWAP Mean Reversion Strategy
// Author: Ugur Pala · github.com/trugurpala/pinescriptv6
// TradingView: https://tr.tradingview.com/u/trugurpala/
//
// TR: Fiyat VWAP'tan uzaklaştığında VWAP'a geri dönüş üzerine işlem yapar.
// Trendsiz / range piyasalarda daha etkilidir.
// EN: Trades mean reversion to VWAP when price extends too far.
// More effective in range / low-trend market conditions.
//
// Sembol / Symbol: CME_MINI:NQ1! veya CME_MICRO:MNQ1!
// Önerilen TF / Recommended TF: 5M, 15M
strategy("NQ VWAP Reversion [trugurpala]",
overlay = true,
initial_capital = 25000,
default_qty_type = strategy.fixed,
default_qty_value = 1,
commission_type = strategy.commission.cash_per_contract,
commission_value = 4.0,
slippage = 1)
// ── Inputs ───────────────────────────────────────────────────────────────────
float devMult = input.float(1.5, "VWAP Band Mult", step=0.1,
tooltip="Kaç standart sapma uzakta / How many std devs away")
int rsiLen = input.int(14, "RSI Filter", minval=1)
float rsiOb = input.float(65, "RSI OB", minval=55, maxval=80)
float rsiOs = input.float(35, "RSI OS", minval=20, maxval=45)
float atrMult = input.float(1.5, "SL Mult", step=0.1)
// ── RTH Filtresi ──────────────────────────────────────────────────────────────
bool inRTH = not na(time(timeframe.period, "0930-1600", "America/New_York"))
bool rthEnd = inRTH[1] and not inRTH
if rthEnd
strategy.close_all(comment="RTH End")
// ── VWAP Hesapla ─────────────────────────────────────────────────────────────
bool newDay = ta.change(time("D")) != 0
var float cumVol = 0.0
var float cumVolPx = 0.0
var float cumVolPx2 = 0.0
if newDay
cumVol := 0.0
cumVolPx := 0.0
cumVolPx2 := 0.0
cumVol += volume
cumVolPx += volume * hlc3
cumVolPx2 += volume * hlc3 * hlc3
float vwapVal = cumVolPx / cumVol
float variance = cumVolPx2 / cumVol - vwapVal * vwapVal
float stdev = math.sqrt(math.max(variance, 0))
float upperBand = vwapVal + devMult * stdev
float lowerBand = vwapVal - devMult * stdev
// ── Sinyaller ────────────────────────────────────────────────────────────────
float rsi = ta.rsi(close, rsiLen)
float atrVal = ta.atr(14)
// Bandın altından VWAP'a dönüş (long)
bool longEntry = ta.crossover(close, lowerBand) and rsi < rsiOs and inRTH and strategy.position_size == 0
// Bandın üstünden VWAP'a dönüş (short)
bool shortEntry = ta.crossunder(close, upperBand) and rsi > rsiOb and inRTH and strategy.position_size == 0
// ── Entries ──────────────────────────────────────────────────────────────────
if longEntry
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", "Long",
stop = close - atrMult * atrVal,
limit = vwapVal) // Hedef VWAP / Target is VWAP
if shortEntry
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", "Short",
stop = close + atrMult * atrVal,
limit = vwapVal)
// ── Visuals ──────────────────────────────────────────────────────────────────
plot(vwapVal, "VWAP", color.new(color.orange, 0), linewidth=2)
p1 = plot(upperBand, "Upper", color.new(color.red, 40))
p2 = plot(lowerBand, "Lower", color.new(color.green, 40))
fill(p1, p2, color.new(color.blue, 93))
bgcolor(not inRTH ? color.new(color.gray, 96) : na)
plotshape(longEntry, "Long", shape.triangleup, location.belowbar, color.green, size=size.small)
plotshape(shortEntry, "Short", shape.triangledown, location.abovebar, color.red, size=size.small)
// ── Alerts (alert() — strategy içinde çalışır) ───────────────────────────────
if longEntry
alert("NQ VWAP Reversion Long — " + str.tostring(close, "#.##"), alert.freq_once_per_bar)
if shortEntry
alert("NQ VWAP Reversion Short — " + str.tostring(close, "#.##"), alert.freq_once_per_bar)
Overview
NQ VWAP Reversion [trugurpala] enters long positions when the price crosses above the lower band while the Relative Strength Index indicates oversold conditions, and takes short positions when price crosses below the upper band with overbought momentum. Entries execute only during regular trading hours with a fixed single-contract position size. Exits occur via an Average True Range multiplier stop loss and an automatic market close at session end. User settings adjust standard deviation multipliers, RSI thresholds, and stop-loss sensitivity.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
VWAP Band Mult
float
1.5
devMult
RSI Filter
int
14
rsiLen
RSI OB
float
65
rsiOb
RSI OS
float
35
rsiOs
SL Mult
float
1.5
atrMult
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This strategy plots VWAP on the price chart and trades only between a start hour and an end hour. It enters long when VWAP is rising and RSI is above a threshold, and short when VWAP is falling and RSI is below a threshold. If the reversal option is on, it clo
This strategy overlays the price chart to trade DAX futures during European market hours. It calculates exponential and simple moving averages, RSI, MACD, Bollinger Bands, ATR, and realized volatility to simulate VIX levels. Trades execute when session time fi
Lucid 100K v5 is a Pine Script strategy for trading MES futures on 5-minute charts. It overlays buy and sell signals directly on the price chart. The strategy runs two phases based on equity and recent profit factor. Phase 1 uses trend pullback entries with EM
This strategy plots entry signals, stop loss, take profit levels, and an information panel directly on the price chart. It combines a relative strength index mean reversion model with ATR percentile thresholds to filter trades based on volatility conditions. T
This mean-reversion trading strategy targets XAUUSD during the Asian trading session. It generates buy signals when price touches the lower Bollinger Band and RSI is oversold, and sell signals when price reaches the upper band and RSI is overbought. Trades are
This strategy identifies Initial Balance periods on NQ and ES futures charts using user-defined start and end hours in Eastern Time. It classifies days as narrow or wide based on average range lookback and skips narrow or trending days per settings. Entries tr