MNQ opening range breakout with three trades a day
A 15-minute opening range from 9:30 New York. A close through it after a close inside it enters from 9:45 to 12:00 when no trade is open. The stop sits at the range's other side and the target at 2R. The day takes up to 3 trades: the script counts the trades that filled since the futures day's first bar. Its input sets the number.
- Trades
- 634
- Won
- 45.7%
- Profit factor
- 1.10
- Net
- +15.4%
- Worst drawdown
- −12.5%
- 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
+$10,599 from 4 November 2024 to 23 February 2026, −$2,876 from 24 February 2026 to 22 October 2026.
//@version=6
// Suggested timeframe: 5-minute
strategy("MNQ opening range breakout with a limit on trades per day", 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)
// ── Trades per day ───────────────────────────────────────────────────────────────────────────────
maxDay = input.int(3, "Trades per day", minval=1, group="Trades per day")
// Count the trades that filled, not the orders sent: a limit entry that never fills is not a trade.
// The count starts again on the futures day's first bar, the 18:00 New York reopen
var int dayStartTrades = 0
if session.isfirstbar
dayStartTrades := strategy.closedtrades + strategy.opentrades
tradesToday = strategy.closedtrades + strategy.opentrades - dayStartTrades
dayOpen = tradesToday < maxDay
// ── The example strategy: a 15-minute opening range breakout ────────────────────────────────────
// Your own entries go here, behind "dayOpen"
orSess = input.session("0930-0945", "Opening range (New York)", group="Strategy")
tradeSess = input.session("0945-1200", "Entry window (New York)", group="Strategy")
rMult = input.float(2.0, "Target (R)", minval=0.5, step=0.5, group="Strategy")
inOR = not na(time(timeframe.period, orSess, "America/New_York"))
inTrade = not na(time(timeframe.period, tradeSess, "America/New_York"))
var float orHigh = na
var float orLow = na
var float stopLevel = na
var float targetLevel = na
if session.isfirstbar
orHigh := na
orLow := na
if inOR
orHigh := na(orHigh) ? high : math.max(orHigh, high)
orLow := na(orLow) ? low : math.min(orLow, low)
// The setup: a close through the range after a close inside it. The stop sits at the range's
// other side and the target at rMult times the risk. A new trade waits until the last one closed
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
canTrade = inTrade and strategy.position_size == 0 and dayOpen and not session.islastbar
if canTrade and longSetup 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)
else if canTrade and shortSetup 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)
if session.islastbar
strategy.close_all("Session end", immediately=true)
// The count, in the Data Window
plot(tradesToday, "Trades today", display=display.data_window)
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)
