Black Friday: 2 years for the price of 1.Or 3 months for the price of 1. On Pro.2 d 5 hleftSee plans →
Free tool

Does the opening range breakout work on gold futures?

We ran 24 opening range breakouts on MGC from 4 November 2024 to 2 November 2026. They start at the 8:20 COMEX open or the 9:30 stock market open. Written in Pine Script? Paste it here: a free account with no card runs it on CME Group futures with $2.50 a contract and a tick of slippage charged.

Free plan · unlimited backtests · no card
MGC's 30-minute opening range at 2R · the 9:30 open against the 8:20 openMGC1! · 5-minute · 4 November 2024 → 2 November 2026
9:30 open over 2 years
+$4,923
8:20 open over 2 years
+$231
9:30 open 24 Feb 2026 → 2 Nov 2026
+$2,021
8:20 open 24 Feb 2026 → 2 Nov 2026
−$2,187
Range from 9:30 New York+$4,923
Range from 8:20 New York+$231
Nov 2024Feb 2026Nov 2026

The $50,000 account after each trade. One MGC contract pays $2.50 a contract each side and a tick of slippage. Dashed: the same 30-minute range from the 8:20 open. Shaded: from 24 February 2026.

Paste your script

Pine v6, as TradingView has it.

MGC's 30-minute opening range at 2R · the 9:30 open against the 8:20 openMGC1! · 5-minute · 4 November 2024 → 2 November 2026
9:30 open over 2 years
+$4,923
8:20 open over 2 years
+$231
9:30 open 24 Feb 2026 → 2 Nov 2026
+$2,021
8:20 open 24 Feb 2026 → 2 Nov 2026
−$2,187
Range from 9:30 New York+$4,923
Range from 8:20 New York+$231
Nov 2024Feb 2026Nov 2026

The $50,000 account after each trade. One MGC contract pays $2.50 a contract each side and a tick of slippage. Dashed: the same 30-minute range from the 8:20 open. Shaded: from 24 February 2026.

One family of settings did: the 9:30 New York range of 30 minutes.

With a target of 1.5R, 2R or 3R it made money in both periods we tested, from 4 November 2024 to 23 February 2026 and from 24 February 2026 to 2 November 2026. Over two years it made $3,201 to $4,923 on MGC 5-minute bars. At 2R it made $2,902 and then made $2,021. We ran 24 settings: the 8:20 COMEX open and the 9:30 stock market open with 5, 15 and 30-minute ranges and four targets. Of those, 6 made money over two years and 3 made money in both periods. The 8:20 open lost money at 11 of its 12 settings.

All 24 settings

OPEN · RANGE · TARGETTRADESWON2 YEARS4 NOV 2024 → 23 FEB 202624 FEB 2026 → 2 NOV 2026WORST DRAWDOWN
8:20 · 5 min · 1R51252.3%−$2,651−$2,335−$316−$4,532
8:20 · 5 min · 1.5R51240.8%−$5,592−$2,602−$2,990−$8,040
8:20 · 5 min · 2R51237.7%−$2,887−$1,544−$1,343−$6,263
8:20 · 5 min · 3R51231.2%−$3,791+$2−$3,793−$7,512
8:20 · 15 min · 1R50849.6%−$6,487−$5,331−$1,156−$9,400
8:20 · 15 min · 1.5R50841.3%−$9,221−$4,981−$4,240−$13,227
8:20 · 15 min · 2R50837%−$8,078−$4,018−$4,060−$11,984
8:20 · 15 min · 3R50834.1%−$7,771−$2,563−$5,208−$11,065
8:20 · 30 min · 1R49852.6%−$2,297−$1,862−$435−$8,022
8:20 · 30 min · 1.5R49846.2%−$760−$772+$12−$8,922
8:20 · 30 min · 2R49842.8%+$231+$2,418−$2,187−$8,235
8:20 · 30 min · 3R49840%−$1,762+$2,554−$4,316−$9,770
9:30 · 5 min · 1R51453.5%−$1,318+$132−$1,450−$4,152
9:30 · 5 min · 1.5R51443.6%−$2,863+$673−$3,536−$6,056
9:30 · 5 min · 2R51439.1%−$2,477+$1,498−$3,975−$5,991
9:30 · 5 min · 3R51435.2%−$2,925+$1,164−$4,089−$6,139
9:30 · 15 min · 1R50453.4%−$1,117+$927−$2,044−$5,501
9:30 · 15 min · 1.5R50447.2%+$392+$1,519−$1,127−$4,632
9:30 · 15 min · 2R50444.4%−$1,132+$459−$1,591−$5,061
9:30 · 15 min · 3R50442.5%−$149+$1,195−$1,344−$5,676
9:30 · 30 min · 1R46550.5%+$714+$1,857−$1,143−$3,823
9:30 · 30 min · 1.5R46548%+$3,850+$2,279+$1,571−$3,027
9:30 · 30 min · 2R46546.7%+$4,923+$2,902+$2,021−$3,423
9:30 · 30 min · 3R46546%+$3,201+$2,052+$1,149−$3,423

One MGC contract on a $50,000 account pays $2.50 a contract each side and a tick of slippage. Entries run until 12:00 New York. The worst drawdown is the deepest fall from a high between 4 November 2024 and 2 November 2026. The 24 settings were fixed before the runs.

The 9:30 range of 30 minutes

At 2R it took 465 trades and won 46.7% of them. It made $4,923 over two years with a worst drawdown of $3,423. Its 4 runs had the 4 smallest drawdowns of the 24: $3,027 to $3,823. From 24 February 2026, 4 of the 24 settings made money and 20 lost. The same 30-minute range from 8:20 made $231 at 2R over two years: it made $2,418 and then lost $2,187.

The script as it ran

MGC 30-minute opening range from 9:30 at 2R

The range is 9:30 to 10:00 New York. Until 12:00 the first 5-minute close outside it enters. The stop sits at the range's other side and the target at 2R. There is one trade a day. Its inputs set the start, the length in minutes and the target.

Trades
465
Won
46.7%
Profit factor
1.12
Net
+9.8%
Worst drawdown
−6.1%
Worst trade
−$891

MGC1! · 5-minute · 4 Nov 2024 → 2 Nov 2026 · $2.50 a contract each side and a tick of slippage · one contract on a $50,000 account

+$2,902 from 4 November 2024 to 23 February 2026, +$2,021 from 24 February 2026 to 2 November 2026.

Pine Script v6 · 64 linesRun this script
//@version=6
// Suggested timeframe: 5-minute (the chart's bars must be no longer than the range)
strategy("Opening range breakout for any session", 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)

// The range: its start on a clock you name and its length in minutes. Name the clock: with no zone,
// hour() and minute() read the exchange's clock (Chicago on CME's NQ and ES, New York on COMEX and NYMEX)
startHour = input.int(9, "Range start: hour", minval=0, maxval=23)
startMin  = input.int(30, "Range start: minute", minval=0, maxval=59)
rangeLen  = input.int(30, "Range length (minutes)", minval=1, maxval=720)
tz        = input.string("America/New_York", "Clock (a time zone name)")
entryLen  = input.int(120, "Entries for (minutes after the range)", minval=1, maxval=1440)
rMult     = input.float(2.0, "Target (R)", minval=0.5, step=0.5)

if timeframe.in_seconds() > rangeLen * 60
    runtime.error("The chart's bars are longer than the range. Use a chart of " + str.tostring(rangeLen) + " minutes or less.")

// Minutes since the range's start on that clock (0 to 1439): a range may cross midnight
since   = (hour(time, tz) * 60 + minute(time, tz) - (startHour * 60 + startMin) + 1440) % 1440
inRange = since < rangeLen
inEntry = since >= rangeLen and since < rangeLen + entryLen

// The range's high and low start on its first bar. They are set once its last bar has closed
// and cleared when the next futures day opens (18:00 New York)
var float orHigh      = na
var float orLow       = na
var bool  isSet       = false
var int   tradesToday = 0
if session.isfirstbar
    isSet       := false
    tradesToday := 0
if inRange
    orHigh := inRange[1] ? math.max(orHigh, high) : high
    orLow  := inRange[1] ? math.min(orLow, low) : low
    isSet  := false
else if inRange[1]
    isSet := true

// The breakout: the first close outside the set range and one trade a day. The stop sits at the
// range's other side and the target at rMult times the risk. The trade closes on the day's last bar
var float stopLevel   = na
var float targetLevel = na
canTrade = isSet and inEntry and strategy.position_size == 0 and tradesToday < 1
if canTrade and close > orHigh and close[1] <= orHigh
    stopLevel   := orLow
    targetLevel := close + (close - orLow) * rMult
    strategy.entry("Long", strategy.long)
    strategy.exit("Long exit", from_entry="Long", stop=stopLevel, limit=targetLevel)
    tradesToday += 1
if canTrade and close < orLow and close[1] >= orLow
    stopLevel   := orHigh
    targetLevel := close - (orHigh - close) * rMult
    strategy.entry("Short", strategy.short)
    strategy.exit("Short exit", from_entry="Short", stop=stopLevel, limit=targetLevel)
    tradesToday += 1
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)
if session.islastbar
    strategy.close_all("Session end", immediately=true)

plot(isSet ? orHigh : na, "Range high", color=color.new(#16A56A, 0), style=plot.style_linebr)
plot(isSet ? orLow : na, "Range low", color=color.new(#E5484D, 0), style=plot.style_linebr)

The code for a range of any session and length is in Opening range high and low in Pine Script. Gold's other tested script is on our gold futures backtester page.

Free account

No card, no time limit.

$0
  • Unlimited backtests, costs charged, with the out-of-sample check
  • The Pine script audit and the full trade list
  • The Pine Copilot writes and edits your script
  • 50 AI credits a day
The Alpha Charts terminal a free account opens: the Pine Copilot beside the chart

Prop Ready opens all two years of futures minute bars on a computer for $39 paid once and has 7 days money back. Pro adds the optimiser and every AI tool and has 30 days money back. See the plans

Questions

Does the opening range breakout work on gold futures?

One family of settings did. The 9:30 New York range of 30 minutes made money in both periods with a target of 1.5R, 2R or 3R: $3,201 to $4,923 over two years on MGC 5-minute bars from 4 November 2024 to 2 November 2026. Of the 24 settings we ran, 6 made money over two years and 3 made money in both periods. The 8:20 COMEX open lost money at 11 of its 12 settings.

Which opening range made the most on gold?

The 9:30 New York range of 30 minutes. At 2R it made $4,923 over two years: it made $2,902 from 4 November 2024 to 23 February 2026 and made $2,021 from 24 February 2026 to 2 November 2026. Its worst drawdown was $3,423. The 4 runs of that range had the 4 smallest drawdowns of the 24: $3,027 to $3,823.

Why the 8:20 and 9:30 opens?

8:20 New York is when COMEX's gold floor session opened. 9:30 is the US stock market's open. Both are New York time on the script's own clock.

Did the opening range make money on gold in 2026?

4 of the 24 settings did from 24 February 2026 to 2 November 2026: the 8:20 30-minute range at 1.5R (+$12); the 9:30 30-minute range at 1.5R (+$1,571); the 9:30 30-minute range at 2R (+$2,021); the 9:30 30-minute range at 3R (+$1,149). The other 20 lost money there.

What were the rules and the costs?

The range starts at 8:20 or 9:30 New York and lasts 5, 15 or 30 minutes. The first 5-minute close outside it until 12:00 enters at the next bar's open. The stop sits at the range's other side. The target is 1, 1.5, 2 or 3 times the risk. There is one trade a day. A trade still open closes on the futures day's last bar. One MGC contract on a $50,000 account pays $2.50 a side and a tick of slippage.

Can I run it myself?

Yes. Run opens the script on MGC 5-minute bars in the Alpha Charts terminal. On a computer, a free account with no card runs it as published on all two years. Its inputs set the start, the length in minutes and the target. A changed input or line makes it your own script: a free account then tests the newest 30 days of a chart under an hour. Prop Ready ($39 paid once) opens all two years for 30 days.

Is a backtest a prediction?

No. It is what a strategy's rules would have done on past prices with costs charged. Live fills, news and your own execution differ. Read it as a test of the rules and not as a forecast.

Every number comes from Alpha Charts' tester on MGC 5-minute bars from 4 November 2024 to 2 November 2026. The runs were made on 27 November 2026. Alpha Charts is software for testing trading scripts and gives no investment advice. A backtest shows what rules would have done on past data. It does not show what they will do. Our methodology is in Data and methodology. Updated 28 November 2026.

Test your Pine Script freeFree account, no cardPaste your script