NQ 15-minute opening range with the 18:00 VWAP filter at 2R
The range is 9:30 to 9:45 New York. From 9:45 to 12:00 the first 5-minute close outside it enters. A long needs a close above the VWAP from 18:00 and a short a close below it. The stop sits at the range's other side and the target at twice the risk; one trade a day. Its VWAP filter input switches to Off or From 9:30.
- Trades
- 472
- Won
- 45.3%
- Profit factor
- 1.05
- Net
- +6.2%
- Worst drawdown
- −14.6%
- Worst trade
- −$749
MNQ1! · 5-minute · 4 Nov 2024 → 22 Oct 2026 · $2.50 a contract each side and a tick of slippage · one contract on a $50,000 account
+$7,639.50 from 4 November 2024 to 23 February 2026, −$4,537 from 24 February 2026 to 22 October 2026.
//@version=6
// Suggested timeframe: 5-minute
strategy("NQ Opening Range Breakout with a VWAP filter", overlay=true, initial_capital=50000, default_qty_type=strategy.fixed, default_qty_value=1,
commission_type=strategy.commission.cash_per_contract, commission_value=2.5, slippage=1, margin_long=0, margin_short=0)
// Inputs: the opening range, the entry window and the target, all on New York's clock
orSess = input.session("0930-0945", "Opening range (New York)")
tradeSess = input.session("0945-1200", "Entry window (New York)")
rMult = input.float(2.0, "Target (R)", minval=0.5, step=0.5)
vwapFrom = input.string("From 18:00", "VWAP filter", options=["Off", "From 18:00", "From 9:30"])
inOR = not na(time(timeframe.period, orSess, "America/New_York"))
inTrade = not na(time(timeframe.period, tradeSess, "America/New_York"))
// The day's state, set back on the futures day's first bar (18:00 New York)
var float orHigh = na
var float orLow = na
var int tradesToday = 0
var float stopLevel = na
var float targetLevel = na
if session.isfirstbar
orHigh := na
orLow := na
tradesToday := 0
// The VWAP the filter reads: from the futures day's 18:00 New York open, or from 9:30 only
var float cumPV = 0.0
var float cumV = 0.0
var float cumPV930 = 0.0
var float cumV930 = 0.0
if session.isfirstbar
cumPV := 0.0
cumV := 0.0
cumPV930 := 0.0
cumV930 := 0.0
cumPV += hlc3 * volume
cumV += volume
if not na(time(timeframe.period, "0930-1600", "America/New_York"))
cumPV930 += hlc3 * volume
cumV930 += volume
vwapDay = cumV > 0 ? cumPV / cumV : na
vwap930 = cumV930 > 0 ? cumPV930 / cumV930 : na
vwapNow = vwapFrom == "From 18:00" ? vwapDay : vwapFrom == "From 9:30" ? vwap930 : na
// Longs only above the VWAP and shorts only below it; with the filter off, both sides trade
longOk = vwapFrom == "Off" or (not na(vwapNow) and close > vwapNow)
shortOk = vwapFrom == "Off" or (not na(vwapNow) and close < vwapNow)
// The setup: the first close outside the opening range; the stop at the range's other side
if inOR
orHigh := na(orHigh) ? high : math.max(orHigh, high)
orLow := na(orLow) ? low : math.min(orLow, low)
rangeSet = not inOR and not na(orHigh)
longSetup = rangeSet and close > orHigh and close[1] <= orHigh
shortSetup = rangeSet and close < orLow and close[1] >= orLow
// One trade a day, one micro contract, inside the window, flat
canTrade = inTrade and strategy.position_size == 0 and tradesToday < 1 and barstate.isconfirmed
if canTrade and longSetup and longOk and orLow < close
stopLevel := orLow
targetLevel := close + (close - orLow) * rMult
strategy.entry("Long", strategy.long)
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=targetLevel)
tradesToday := tradesToday + 1
if canTrade and shortSetup and shortOk and orHigh > close
stopLevel := orHigh
targetLevel := close - (orHigh - close) * rMult
strategy.entry("Short", strategy.short)
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=targetLevel)
tradesToday := tradesToday + 1
// The same stop and target on every bar of the trade; flat on the session's last bar
if strategy.position_size > 0
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=targetLevel)
if strategy.position_size < 0
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=targetLevel)
if session.islastbar
strategy.close_all("Session end", immediately=true)
plot(rangeSet ? orHigh : na, "Range high", color=color.new(#16A56A, 0), style=plot.style_linebr)
plot(rangeSet ? orLow : na, "Range low", color=color.new(#E5484D, 0), style=plot.style_linebr)
plot(vwapNow, "VWAP", color=color.new(#3D69A8, 0), style=plot.style_linebr)
