NQ break of structure and order block retest at 2R
A 5-minute close through the last swing high or low is a break of structure. The order block is the last opposite candle before the move that broke it. From 9:30 to 15:30 New York a limit order waits at the order block's near side. The stop sits a tick beyond its far side and the target at 2R. One trade a day and flat by 16:00. Its inputs switch the entry to the break and set the target.
- Trades
- 438
- Won
- 32.0%
- Profit factor
- 0.78
- Net
- −11.7%
- Worst drawdown
- −12.4%
- Worst trade
- −$323.50
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
−$4,078.50 from 4 November 2024 to 23 February 2026, −$1,761.50 from 24 February 2026 to 22 October 2026.
//@version=6
// Suggested timeframe: 5-minute
strategy("NQ break of structure and order block", 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, max_bars_back=2000)
// Inputs: how to enter after a structure break, the target, and the size of a swing
entryMode = input.string("Order block retest", "Entry", options=["Order block retest", "On the break"])
rMult = input.float(2.0, "Target (R)", minval=0.5, step=0.5)
swingLen = input.int(5, "Bars each side of a swing", minval=1)
// New York's clock: breaks count for a trade from 9:30 to 15:30, flat at 16:00
canTrade = not na(time(timeframe.period, "0930-1530", "America/New_York")) and not session.islastbar
lastNY = not na(time(timeframe.period, "1555-1600", "America/New_York"))
// Swings, read on every bar round the clock: a high with swingLen lower highs on each side (a low with
// swingLen higher lows), known swingLen bars after it
ph = ta.pivothigh(high, swingLen, swingLen)
pl = ta.pivotlow(low, swingLen, swingLen)
var float swingHi = na
var int swingHiBar = na
var bool hiBroken = true
var float swingLo = na
var int swingLoBar = na
var bool loBroken = true
if not na(ph)
swingHi := ph
swingHiBar := bar_index - swingLen
hiBroken := false
if not na(pl)
swingLo := pl
swingLoBar := bar_index - swingLen
loBroken := false
// A structure break: a close above the last swing high, or below the last swing low. Each swing breaks
// once. The high is checked first
bullBreak = not hiBroken and close > swingHi
bearBreak = not loBroken and close < swingLo and not bullBreak
if bullBreak
hiBroken := true
if bearBreak
loBroken := true
// The bullish order block: the last down candle (close below open) before the rally that broke the
// swing high. The rally starts at the lowest low between the swing high and the break (the latest bar
// if several share it); the search goes back from there to the swing high's bar
bullOB() =>
span = bar_index - swingHiBar
lowAt = 1
obTop = float(na)
obBot = float(na)
if span >= 1 and span < 1990
for i = 1 to span
if low[i] < low[lowAt]
lowAt := i
for i = lowAt to span
if close[i] < open[i]
obTop := high[i]
obBot := low[i]
break
[obTop, obBot]
// The bearish order block: the last up candle before the drop that broke the swing low
bearOB() =>
span = bar_index - swingLoBar
highAt = 1
obTop = float(na)
obBot = float(na)
if span >= 1 and span < 1990
for i = 1 to span
if high[i] > high[highAt]
highAt := i
for i = highAt to span
if close[i] > open[i]
obTop := high[i]
obBot := low[i]
break
[obTop, obBot]
// One trade a futures day: filled trades counted from the session's first bar
var int tradesAtStart = 0
if session.isfirstbar
tradesAtStart := strategy.closedtrades + strategy.opentrades
dayTrades = strategy.closedtrades + strategy.opentrades - tradesAtStart
// After a break, a limit order at the order block's near side (Order block retest) or a market order
// (On the break). The stop is a tick beyond the order block's far side; the target is rMult times the
// risk. A new break replaces a waiting order
var float stopLevel = na
var float targetLevel = na
if canTrade and strategy.position_size == 0 and dayTrades < 1
if bullBreak
[obTop, obBot] = bullOB()
strategy.cancel("Short")
if not na(obTop) and close > obTop
stopLevel := obBot - syminfo.mintick
if entryMode == "Order block retest"
targetLevel := obTop + (obTop - stopLevel) * rMult
strategy.entry("Long", strategy.long, limit=obTop)
else
targetLevel := close + (close - stopLevel) * rMult
strategy.entry("Long", strategy.long)
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=targetLevel)
else
strategy.cancel("Long")
else if bearBreak
[obTop, obBot] = bearOB()
strategy.cancel("Long")
if not na(obBot) and close < obBot
stopLevel := obTop + syminfo.mintick
if entryMode == "Order block retest"
targetLevel := obBot - (stopLevel - obBot) * rMult
strategy.entry("Short", strategy.short, limit=obBot)
else
targetLevel := close - (stopLevel - close) * rMult
strategy.entry("Short", strategy.short)
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=targetLevel)
else
strategy.cancel("Short")
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)
// A waiting order ends when the entry window closes; flat at 16:00, or on the session's last bar when
// the market closes early (a holiday half day) or halts for a long weekend
if not canTrade or dayTrades >= 1
strategy.cancel("Long")
strategy.cancel("Short")
if lastNY or session.islastbar
strategy.close_all("Close", immediately=true)
plot(swingHi, "Last swing high", color=color.new(#E5484D, 30), style=plot.style_stepline)
plot(swingLo, "Last swing low", color=color.new(#16A56A, 30), style=plot.style_stepline)
