The paper's rule: the first candle's direction, a 10R target
Long if the first 5-minute candle from 9:30 New York closes up, short if it closes down, at the second candle's open; the stop at the first candle's far end, the target at 10 times the risk, out at 16:00.
- Trades
- 512
- Won
- 27.3%
- Profit factor
- 1.03
- Net
- +9.6%
- Worst drawdown
- −28.8%
- Worst trade
- −$652 on a $500 risk
MNQ1! · 5-minute · 23 October 2024 → 22 October 2026 · 2 years · 517 sessions · $0.75 a contract each side, one tick of slippage, $50,000 account, 1% risk
+22.3% in the first 16 months, -10.4% in the last 8. 27.3% of trades won.
//@version=6
// Suggested timeframe: 5-minute
strategy("NQ 5-minute ORB, the Zarattini and Aziz rule", overlay=true, initial_capital=50000, default_qty_type=strategy.fixed, default_qty_value=1,
commission_type=strategy.commission.cash_per_contract, commission_value=0.75, slippage=1, margin_long=0, margin_short=0)
// The paper's rule (Zarattini and Aziz, 2023): the first 5-minute candle's direction decides the day's trade,
// entered at the second candle's open; no trade on a doji; the stop at the first candle's far end; the target
// 10 times the risk, or out at the close; 1% of the account at risk, at most 4 times the account in exposure
riskPct = input.float(1.0, "Risk % per trade", minval=0.1, step=0.1)
targetR = input.float(10.0, "Target (R)", minval=0.5, step=0.5)
maxLeverage = input.float(4.0, "Maximum leverage", minval=0.5, step=0.5)
maxContracts = input.int(10, "Max contracts", minval=1)
// New York's clock: the first candle is 9:30 to 9:35; the close is 16:00
firstCandle = not na(time(timeframe.period, "0930-0935", "America/New_York"))
lastCandle = not na(time(timeframe.period, "1555-1600", "America/New_York"))
var float stopLevel = na
var float targetLevel = na
// On the first candle's close: the order fills at the second candle's open
if firstCandle and barstate.isconfirmed and strategy.position_size == 0 and close != open and high > low
longDay = close > open
stopAt = longDay ? low : high
riskPts = math.abs(close - stopAt)
equity = math.max(strategy.equity, 0)
byRisk = equity * riskPct / 100 / ((riskPts + 2 * syminfo.mintick) * syminfo.pointvalue)
byLever = maxLeverage * equity / (close * syminfo.pointvalue)
qty = math.min(maxContracts, math.floor(math.min(byRisk, byLever)))
if qty >= 1 and riskPts > 0
stopLevel := stopAt
targetLevel := longDay ? close + targetR * riskPts : close - targetR * riskPts
if longDay
strategy.entry("Long", strategy.long, qty=qty)
strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=targetLevel)
else
strategy.entry("Short", strategy.short, qty=qty)
strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=targetLevel)
// The same stop and target on every bar of the trade
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)
// Out at the close: ordered on the 15:55 candle, filled at 16:00
if lastCandle and strategy.position_size != 0
strategy.close_all(comment="16:00 close")
plot(strategy.position_size != 0 ? stopLevel : na, "Stop", color=color.new(#E5484D, 0), style=plot.style_linebr)
plot(strategy.position_size != 0 ? targetLevel : na, "Target", color=color.new(#16A56A, 0), style=plot.style_linebr)