MNQ opening range breakout with a $500 daily target in the trade's limit
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. The day takes up to 3 trades. The stop sits at the range's other side and the target at 2R. The $500 daily target is in each trade's limit from the candle after its fill: the nearer of the 2R target and the price where the day reaches $500 after the trade's commission. 5 MNQ contracts. Its input sets how the target acts: off, closed trades only, checked at each close or in the trade's limit.
- Trades
- 607
- Won
- 64.6%
- Profit factor
- 1.07
- Net
- +33.4%
- Worst drawdown
- −24.3%
- Worst trade
- −$2,912.50
MNQ1! · 5-minute · 4 Nov 2024 → 22 Oct 2026 · $2.50 a contract each side and a tick of slippage · 5 contracts on a $50,000 account
+$17,507.50 from 4 November 2024 to 23 February 2026, −$807.50 from 24 February 2026 to 22 October 2026.
//@version=6
// Suggested timeframe: 5-minute
strategy("MNQ opening range breakout with a daily profit target", overlay=true, initial_capital=50000, default_qty_type=strategy.fixed, default_qty_value=5,
commission_type=strategy.commission.cash_per_contract, commission_value=2.5, slippage=1, margin_long=0, margin_short=0)
// ── The daily profit target ──────────────────────────────────────────────────────────────────────
// An example number: take yours from your own plan
dpTarget = input.float(500, "Daily profit target ($)", minval=1, group="Daily profit target")
dpMode = input.string("In the trade's limit", "How the target acts", options=["Off", "Closed trades only", "Checked at each close", "In the trade's limit"], group="Daily profit target")
dpFee = input.float(2.5, "Commission per contract each side ($)", minval=0, group="Daily profit target")
// The day's books: what the day's closed trades made after their costs. A futures day starts at
// its first bar, the 18:00 New York reopen
var float dpBooked = 0.0 // the day's closed trades, after their costs
var int dpSeen = 0 // closed trades already counted
var bool dpHit = false // the target was reached: no more trades today
var int dpDays = 0 // days the target ended
while dpSeen < strategy.closedtrades
dpBooked += strategy.closedtrades.profit(dpSeen)
dpSeen += 1
if session.isfirstbar
dpBooked := 0.0
dpHit := false
// What the open trade would add if it closed at a price, after its commission both ways
dpOpenAt(price) =>
strategy.position_size == 0 ? 0.0 : (price - strategy.position_avg_price) * strategy.position_size * syminfo.pointvalue - 2 * dpFee * math.abs(strategy.position_size)
// The target as a price: where a trade of this size from this entry takes the day to the target
dpPriceLong(entry, size) =>
entry + (dpTarget - dpBooked + 2 * dpFee * size) / (size * syminfo.pointvalue)
dpPriceShort(entry, size) =>
entry - (dpTarget - dpBooked + 2 * dpFee * size) / (size * syminfo.pointvalue)
// Closed trades only: the day stops once its booked trades reach the target
if dpMode != "Off" and not dpHit and dpBooked >= dpTarget - 0.005
dpHit := true
dpDays += 1
// Checked at each close: the open trade counted at the candle's close, and closed there
if dpMode == "Checked at each close" and not dpHit and strategy.position_size != 0 and dpBooked + dpOpenAt(close) >= dpTarget
strategy.close_all(comment="Daily target", immediately=true)
dpHit := true
dpDays += 1
// ── The example strategy: a 15-minute opening range breakout, up to three trades a day ──────────
// Your own entries go here, behind "not dpHit", with the target's price in the exit
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")
maxDay = input.int(3, "Trades per day", minval=1, group="Strategy")
qty = input.int(5, "Contracts", minval=1, 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 int tradesToday = 0
var float stopLevel = na
var float targetLevel = na
if session.isfirstbar
orHigh := na
orLow := na
tradesToday := 0
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 tradesToday < maxDay and not dpHit and not session.islastbar
useLimit = dpMode == "In the trade's limit"
if canTrade and longSetup and orLow < close
stopLevel := orLow
targetLevel := close + (close - orLow) * rMult
strategy.entry("Long", strategy.long, qty=qty)
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=targetLevel)
tradesToday += 1
if canTrade and shortSetup and orHigh > close
stopLevel := orHigh
targetLevel := close - (orHigh - close) * rMult
strategy.entry("Short", strategy.short, qty=qty)
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=targetLevel)
tradesToday += 1
// From the candle after the fill: the same stop, and the nearer of the target and the day's target
// price, worked out from the fill's own price. The entry is a market order, so its price is known only
// at the fill candle's close: a trade that goes past the target on that first candle closes at the next open
if strategy.position_size > 0
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=useLimit ? math.min(targetLevel, dpPriceLong(strategy.position_avg_price, strategy.position_size)) : targetLevel)
if strategy.position_size < 0
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=useLimit ? math.max(targetLevel, dpPriceShort(strategy.position_avg_price, -strategy.position_size)) : targetLevel)
if session.islastbar
strategy.close_all("Session end", immediately=true)
// The tally, in the Data Window
plot(dpBooked, "Today's booked P&L", display=display.data_window)
plot(dpDays, "Days the target ended", 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)
