NQ 15-minute opening range entered on the retest at 2R
The range is 9:30 to 9:45 New York. The day's first 5-minute close outside it between 9:45 and 12:00 sets the side. A limit order then waits at the broken level until 12:00. The stop sits at the range's other side and the target at twice the range; one trade a day. Its Entry input switches to Break.
- Trades
- 429
- Won
- 43.8%
- Profit factor
- 1.08
- Net
- +7.7%
- Worst drawdown
- −11.8%
- Worst trade
- −$646
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,018.50 from 4 November 2024 to 23 February 2026, −$3,184.50 from 24 February 2026 to 22 October 2026.
//@version=6
// Suggested timeframe: 5-minute
strategy("NQ Opening Range: break or retest", 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, the target and how to enter, 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)
entryMode = input.string("Retest", "Entry", options=["Break", "Retest"])
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 int breakDir = 0
var int dayStart = 0
var float stopLevel = na
var float targetLevel = na
if session.isfirstbar
orHigh := na
orLow := na
tradesToday := 0
breakDir := 0
dayStart := strategy.closedtrades + strategy.opentrades
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)
breakUp = rangeSet and close > orHigh and close[1] <= orHigh
breakDn = rangeSet and close < orLow and close[1] >= orLow
// The day's first break inside the window sets the side; only that break is traded
if inTrade and barstate.isconfirmed and breakDir == 0 and tradesToday < 1
breakDir := breakUp ? 1 : breakDn ? -1 : 0
if breakDir != 0 and entryMode == "Break"
// Break: enter at the next bar's open, the stop at the range's other side
if breakDir == 1 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 := 1
if breakDir == -1 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 := 1
// A filled retest is the day's one trade, even one that hits its stop or target on the bar it fills
if strategy.closedtrades + strategy.opentrades > dayStart
tradesToday := 1
// Retest: after the break, a limit order at the broken level until 12:00; the stop at the range's
// other side, so the risk is the range itself
if entryMode == "Retest" and inTrade and tradesToday < 1 and strategy.position_size == 0 and breakDir != 0
if breakDir == 1
stopLevel := orLow
targetLevel := orHigh + (orHigh - orLow) * rMult
strategy.entry("Long", strategy.long, limit=orHigh)
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=targetLevel)
if breakDir == -1
stopLevel := orHigh
targetLevel := orLow - (orHigh - orLow) * rMult
strategy.entry("Short", strategy.short, limit=orLow)
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=targetLevel)
// An unfilled retest is cancelled when the window closes
if not inTrade and strategy.position_size == 0
strategy.cancel("Long")
strategy.cancel("Short")
// 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)
