MNQ opening range breakout with a 30% consistency cap
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. Each day stops at 30% of a $3,000 profit target: the cap's price is in each trade's limit from the candle after its fill. 5 MNQ contracts. The Data Window shows the biggest day and its share of the profit.
- Trades
- 621
- Won
- 56.4%
- Profit factor
- 1.14
- Net
- +80.2%
- Worst drawdown
- −21.7%
- 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
+$38,270 from 4 November 2024 to 23 February 2026, +$1,840 from 24 February 2026 to 22 October 2026.
//@version=6
// Suggested timeframe: 5-minute
strategy("MNQ opening range breakout with a consistency cap", 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 consistency rule ─────────────────────────────────────────────────────────────────────────
// Example numbers, not any firm's: take yours from your plan's own page
csTarget = input.float(3000, "Profit target ($)", minval=1, group="Consistency rule")
csShare = input.float(30, "Most of the profit one day may make (%)", minval=1, maxval=100, group="Consistency rule")
csCapOn = input.bool(true, "Stop each day at that share of the target", group="Consistency rule")
csFee = input.float(2.5, "Commission per contract each side ($)", minval=0, group="Consistency rule")
csFrom = input.time(timestamp("2000-01-01"), "Count from your evaluation's start", group="Consistency rule")
// The books, from the closed trades after their costs: the day's profit, the profit so far and the
// biggest day so far. They count only the trades that close from csFrom on: set it to your
// evaluation's start. A futures day starts at its first bar, the 18:00 New York reopen
var float csDay = 0.0
var float csTotal = 0.0
var float csTop = 0.0
var int csSeen = 0
var bool csHit = false
while csSeen < strategy.closedtrades
if strategy.closedtrades.exit_time(csSeen) >= csFrom
csDay += strategy.closedtrades.profit(csSeen)
csTotal += strategy.closedtrades.profit(csSeen)
csSeen += 1
csTop := math.max(csTop, csDay)
if session.isfirstbar
csDay := 0.0
csHit := false
// The check: the biggest day's share of the profit so far
csTopShare = csTotal > 0 ? csTop / csTotal * 100 : na
// The cap: a day that stops at the share of the target can never be more than that share of a
// profit that reached the target. Its price goes in the trade's limit, as for a daily profit target
csCap = csShare / 100 * csTarget
csPriceLong(entry, size) =>
entry + (csCap - csDay + 2 * csFee * size) / (size * syminfo.pointvalue)
csPriceShort(entry, size) =>
entry - (csCap - csDay + 2 * csFee * size) / (size * syminfo.pointvalue)
if csCapOn and not csHit and csDay >= csCap - 0.005
csHit := true
// ── The example strategy: a 15-minute opening range breakout, up to three trades a day ──────────
// Your own entries go here, behind "not csHit", with the cap'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 csHit and not session.islastbar
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 cap's 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 cap on that first candle closes at the next open
if strategy.position_size > 0
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=csCapOn ? math.min(targetLevel, csPriceLong(strategy.position_avg_price, strategy.position_size)) : targetLevel)
if strategy.position_size < 0
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=csCapOn ? math.max(targetLevel, csPriceShort(strategy.position_avg_price, -strategy.position_size)) : targetLevel)
if session.islastbar
strategy.close_all("Session end", immediately=true)
// The check, in the Data Window
plot(csTop, "Biggest day ($)", display=display.data_window)
plot(csTopShare, "Biggest day's share of the profit (%)", 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)
