Skip to content
ViprasolWE SOLVE INFINITYGet started
Back to Blog

ORB Trading Strategy: Opening Range Breakout Rules and Code

A practical guide to the opening range breakout: how the range is defined, which filters matter, how to size a trade, and how to code an ORB indicator.

Viprasol Tech Team
16 min read
Updated 2026

ORB Trading Strategy: Opening Range Breakout Rules and Code

TLDR

An opening range breakout (ORB) strategy marks the high and low of the first N minutes of a trading session, then enters in the direction of the first close beyond that range, with a stop inside the range and a target expressed as a multiple of the stop distance. The 15 minute ORB is the most common variant, but the range length, the filters you add and the way you size the position matter more than the exact number. This article gives you a complete rule set, the arithmetic for one trade, an original Pine Script v6 indicator, and an honest list of the ways ORB fails.

What the opening range actually measures

The first minutes after a session opens are when overnight orders, news reactions and the first wave of institutional flow get processed. The high and low printed during that window summarize where early buyers and sellers were willing to transact. An ORB strategy treats a decisive move out of that window as evidence that one side has been absorbed and the other side is in control for at least the next leg.

That is the whole thesis. It is not a prediction model; it is a rule for reacting to displayed intent, with a stop placed where the thesis is wrong. Everything else in an ORB system is risk management and filtering.

Three things define the setup:

  • The session. For US equities and index futures this is usually the cash open (09:30 America/New_York). For forex many traders use the London open (08:00 Europe/London) or the New York open. Crypto has no official open, so traders pick a fixed UTC hour, which weakens the logic because there is no concentrated flow at that moment.
  • The range length. 5, 15, 30 and 60 minutes are the usual choices. Shorter ranges produce more signals and more false breakouts; longer ranges produce fewer, later signals with wider stops.
  • The breakout rule. A close beyond the range on the trading timeframe is the standard rule. Some traders use a tick beyond the range (faster, more noise) or a close plus a buffer (slower, fewer fakeouts).

A complete ORB rule set

Below is a rule set that is specific enough to code and test. Treat the numbers as starting parameters, not as validated settings.

Range definition

  1. Session: regular trading hours of the instrument, in the exchange timezone.
  2. Opening range: the highest high and lowest low of all bars whose open time falls inside the first 15 minutes of the session.
  3. The range is frozen after minute 15. No trades are taken while the range is forming.

Entry

  1. Long: the first 5 minute bar (or 1 minute bar, if you want to be faster) that closes above the range high after the range is frozen.
  2. Short: the first bar that closes below the range low.
  3. One long attempt and one short attempt per session at most. After both have fired, or after a configurable cut-off time such as 11:30, no new entries.

Stop and target

  1. Initial stop: the midpoint of the opening range for the default version, or the opposite side of the range for the conservative version.
  2. Target: 2R, where R is the distance from entry to stop. Optionally scale out half at 1R and move the stop to breakeven.
  3. Time stop: close anything still open at a fixed time before the session close so you do not carry intraday risk into the closing auction.

Filters

  1. Range size filter: skip the day if the range is smaller than 0.3 times the 14 period ATR of the trading timeframe. Tiny ranges produce stops so tight that normal noise takes you out.
  2. Range size ceiling: skip the day if the range is larger than roughly 1.5 times the daily ATR. A huge opening range usually means the move already happened.
  3. Gap alignment: for equities, prefer breakouts in the direction of the overnight gap. Fading the gap direction is a different strategy.
  4. Higher timeframe bias: take longs only when price is above the prior day close, or above a slow moving average, and vice versa. This is a confluence filter; see the article on confluence in trading for how to combine factors without over-filtering.

Choosing the range length: 5, 15, 30 or 60 minutes

There is no universally correct window. The trade-off is between information and timeliness. A longer window contains more of the morning auction and therefore a better estimate of where the market has agreed on value, but it also means a later entry and often a wider stop. The table below summarizes what you should expect from each, based on how the mechanics work rather than on any claimed performance figure.

Range lengthTypical stop widthSignal frequencyMain weaknessFits best
5 minutesVery tightHigh; most days produce a breakWhipsaw in the first 20 minutes while the real range is still formingScalpers on liquid index futures who accept many small losses
15 minutesModerateMost daysStill vulnerable to the 09:45 to 10:00 reversal window on US equitiesThe default for most discretionary and automated ORB traders
30 minutesWiderFewer; some days never break cleanlyEntry can be late; first leg often finished before signalSwing-style day traders, higher ATR instruments
60 minutesWideLowRange often covers most of the day's extension; targets rarely reachedTraders who hold toward the close, or multi-day breakouts

If you only test one, test 15 minutes on a liquid instrument with a defined open, then test 5 and 30 minutes on the same data so you understand the shape of the sensitivity, not just one number.

Worked example: one ORB trade with the arithmetic shown

This example is illustrative. The prices are chosen to make the math easy to follow; it is not a record of a real trade.

Setup. Account size 50,000 USD. Risk per trade 1 percent, which is 500 USD. Instrument: an index future that moves 50 USD per full point per contract (E-mini S&P 500 futures have this multiplier; check the exchange contract specification for the instrument you trade).

Opening range (09:30 to 09:45). High 5,010.00, low 5,000.00. Range = 10.00 points. The 14 period ATR on the 5 minute chart is 6.00 points, so 0.3 times ATR is 1.80 points; the range passes the minimum size filter. The daily ATR is 45 points, so 1.5 times daily ATR is 67.5 points; the range passes the ceiling filter.

Entry. The 09:55 5 minute bar closes at 5,011.50, above the range high. Long is triggered. For simplicity, assume the fill is at the open of the next bar, 5,011.75.

Stop. Midpoint of the range = (5,010.00 + 5,000.00) / 2 = 5,005.00. Stop distance = 5,011.75 - 5,005.00 = 6.75 points.

Position size. Risk per contract = 6.75 points x 50 USD = 337.50 USD. Allowed risk 500 USD. Contracts = floor(500 / 337.50) = 1 contract. (Two contracts would risk 675 USD, which breaks the 1 percent rule.) Actual risk taken = 337.50 USD, or 0.675 percent of the account.

Target. 2R = 2 x 6.75 = 13.50 points above entry = 5,025.25. If filled there, gross profit = 13.50 x 50 = 675.00 USD, before commissions and slippage.

Commission and slippage. If round-trip commission is 4.00 USD and you assume one tick (0.25 point = 12.50 USD) of slippage on each side, the trade costs 29.00 USD. Net winning trade is 646.00 USD; net losing trade is -366.50 USD. Your realized reward-to-risk is 646 / 366.5 = 1.76, not 2.0. That gap is the first thing most ORB backtests get wrong.

Breakeven win rate. With a realized R of 1.76, the win rate that produces zero expectancy is 1 / (1 + 1.76) = 36.2 percent. Any system with a 2:1 target needs to win more than about a third of the time after costs. Whether your market and your filters clear that bar is something only your own backtest, forward test and live log can tell you.

Original Pine Script v6 ORB indicator

The script below marks the opening range, draws the frozen levels, applies the minimum range filter, fires one long and one short signal per session on confirmed bars, and exposes alert conditions. It is written for TradingView Pine Script v6 and kept short on purpose so you can read every line.

//@version=6
indicator("Opening Range Breakout (ORB)", overlay = true)

rangeMinutes = input.int(15, "Opening range length (minutes)", minval = 1) sess = input.session("0930-1600", "Session") tz = input.string("America/New_York", "Timezone") atrLen = input.int(14, "ATR length", minval = 1) minRangeAtr = input.float(0.3, "Min range as fraction of ATR", step = 0.05)

inSession = not na(time(timeframe.period, sess, tz)) newSession = inSession and not inSession[1] sessStart = ta.valuewhen(newSession, time, 0) inRange = inSession and time < sessStart + rangeMinutes * 60 * 1000

var float orHigh = na var float orLow = na var bool orDone = false var bool firedLong = false var bool firedShort = false

if newSession orHigh := high orLow := low orDone := false firedLong := false firedShort := false else if inRange orHigh := math.max(orHigh, high) orLow := math.min(orLow, low)

if inSession and not inRange orDone := true

atr = ta.atr(atrLen) rangeOk = (orHigh - orLow) >= minRangeAtr * atr longBreak = orDone and rangeOk and not firedLong and close > orHigh and barstate.isconfirmed shortBreak = orDone and rangeOk and not firedShort and close < orLow and barstate.isconfirmed

if longBreak firedLong := true if shortBreak firedShort := true

plot(orDone ? orHigh : na, "OR High", color = color.green, style = plot.style_linebr) plot(orDone ? orLow : na, "OR Low", color = color.red, style = plot.style_linebr) plotshape(longBreak, "Long break", shape.triangleup, location.belowbar, color.green, size = size.small) plotshape(shortBreak, "Short break", shape.triangledown, location.abovebar, color.red, size = size.small) alertcondition(longBreak, "ORB long", "ORB long breakout") alertcondition(shortBreak, "ORB short", "ORB short breakout")

Notes on the design choices:

  • barstate.isconfirmed keeps the signal from flickering while the current bar is still open. Without it the indicator repaints intrabar. See non-repainting indicators for the full explanation.
  • The range is built from the bars of the chart timeframe, so on a 5 minute chart a 15 minute range is exactly three bars. On a 1 minute chart it is fifteen bars. If you load this on a 30 minute chart the range will be one bar and the logic degrades; the indicator does not try to hide that.
  • The ATR filter uses the chart timeframe ATR. If you want the daily ATR ceiling filter, add a request.security call for the daily ATR and compare against it.
  • The script does not handle holidays with shortened sessions. The session input assumes a normal day.

Turning this into a strategy script for the TradingView strategy tester is mostly a matter of replacing the plotshape calls with strategy.entry and strategy.exit, with the stop at the range midpoint and the limit at 2R. If you want the signals to drive a broker, the alert messages feed a webhook trading bridge; the mechanics are covered in the TradingView webhooks article.

The same range logic in MQL5

If you run the strategy as an MT5 expert advisor, the opening range has to be rebuilt from M1 history on each new day. The function below returns the high and low between the session open and open plus N minutes using CopyRates. It assumes the server time of your broker matches the session you care about; for US index CFDs on a broker with a non-New York server clock you need an offset input.

// Returns true and fills orHigh / orLow when the opening range is complete.
bool GetOpeningRange(const string symbol, const datetime sessionOpen,
                     const int rangeMinutes, double &orHigh, double &orLow)
{
   datetime rangeEnd = sessionOpen + rangeMinutes * 60;
   if(TimeCurrent() < rangeEnd)
      return false;                       // range still forming

MqlRates rates[]; int copied = CopyRates(symbol, PERIOD_M1, sessionOpen, rangeEnd - 60, rates); if(copied < rangeMinutes) return false; // missing M1 history, do not trade on partial data

orHigh = rates[0].high; orLow = rates[0].low; for(int i = 1; i < copied; i++) { if(rates[i].high > orHigh) orHigh = rates[i].high; if(rates[i].low < orLow) orLow = rates[i].low; } return true; }

The guard on copied < rangeMinutes is important. A common EA bug is building the range from whatever bars happen to exist after a reconnect, which produces a narrow phantom range and a trade that should never have fired. Refusing to trade on partial data is the correct failure mode. The full EA also needs the one-attempt-per-direction flags, the cut-off time, and a daily reset; our MT5 expert advisor development page describes how we structure that.

Where ORB breaks down

A breakout system has to be honest about the days it loses. These are the recurring failure modes you will see in any ORB log.

The 09:45 to 10:15 reversal

On US equities and index futures, the first breakout after the 15 minute range frequently fails and reverses as the second wave of institutional orders arrives. With a midpoint stop you will take the full loss on those days. Some traders handle this with a re-entry rule: if the first break fails and price then breaks the opposite side, take that trade. That doubles the number of trades and the number of losing days on choppy sessions, so it must be tested, not assumed.

Narrow range days

Low volatility opens produce ranges so small that the stop sits inside normal noise. The ATR filter removes the worst of these, but it also removes some of the cleanest trend days, because a quiet open sometimes precedes a strong afternoon. You are trading one error for another.

News at or after the open

Scheduled releases at 10:00 New York (several US economic indicators publish at that time) land right in the window where the first ORB signal is usually live. A news filter that blocks entries in the minutes around scheduled releases is standard in automated versions; see the prop firm EA rules article for how this is normally implemented, because most prop firms require it anyway.

Slippage on the break

The breakout bar is by definition a bar where everyone else saw the same level. Market orders at that moment fill worse than the average bar. The worked example above used one tick per side. On thinner instruments and in fast markets the real number is larger, and it compresses your realized R further.

Parameter sensitivity

If your backtest results change dramatically when you move the range length from 15 to 20 minutes, or the ATR multiplier from 0.3 to 0.4, the edge is probably an artifact of the specific data. A stable system should degrade gracefully as parameters shift. This is one of the standard checks in our backtesting service, and the comparison of tools for doing it lives in backtesting platforms compared.

Testing an ORB strategy properly

Because ORB is a session-anchored intraday strategy, a few testing details matter more than usual.

  • Timezone correctness. Verify that the bars you believe are the first 15 minutes really are. Daylight saving transitions shift the relationship between UTC and exchange time twice a year, and a broker server clock that does not follow New York will silently move your range.
  • Bar construction. A 5 minute bar built by one data vendor can differ from another vendor's 5 minute bar because of how the vendor aligns bar boundaries and treats the opening print. Test on the data you will trade on.
  • Costs in the model. Include commission and a realistic slippage assumption on both entry and exit. Breakout strategies are more sensitive to this than mean-reversion strategies because their entries happen at moments of imbalance.
  • Out-of-sample window. Fit parameters on one period, then run them unchanged on a later period you have not looked at. If the out-of-sample result is much worse, you have overfit.
  • Regime split. Report results separately for high and low volatility periods. ORB behaves differently when the daily ATR is expanding versus contracting, and an aggregate number hides that.

Discretionary versus automated ORB

Discretionary traders often outperform their own mechanical rules on ORB because they skip obviously bad days: a holiday session, a day with a major announcement due, a day when the first 15 minutes contained a halt. The automated version has to encode each of those skips explicitly or accept the losses. The upside of automation is consistency: the mechanical version will never widen a stop, never hesitate on a clean break, and never take a revenge trade at 11:00. The usual compromise is an automated signal with a manual veto, which is what most traders end up building with a TradingView alert plus a confirmation step.

If you want the indicator above extended with a daily ATR ceiling, a gap filter, session presets for London and New York, a built-in strategy tester version, and a settings panel, that is the kind of work we do under TradingView Pine Script development. If you already have a Pine version and need it running on MT5, the Pine Script to MQL5 conversion service exists for exactly that handoff.

FAQ

What is the best time frame for an ORB strategy?

There is no best time frame. The 15 minute range on a 5 minute chart is the most common starting point for US index futures because it covers the first burst of order flow without waiting too long. Test 5, 15 and 30 minutes on your own instrument and look at how smoothly the results change, not just which one is highest.

Does the ORB strategy work on forex and crypto?

The logic depends on a concentrated open. Forex has recognizable session opens in London and New York, so the concept transfers, although the ranges are usually defined on the first 30 or 60 minutes because the open is less abrupt. Crypto trades continuously, so an opening range anchored to an arbitrary UTC hour has a weaker rationale. Some traders anchor to the US equity open instead, because that is when volume in major crypto pairs tends to pick up, but you should verify that on your own data.

Where should the stop go on an ORB trade?

The two standard placements are the midpoint of the range and the opposite side of the range. The midpoint gives a tighter stop and a larger position for the same risk, but gets hit by normal retests. The opposite side survives retests but requires a smaller position and a target further away to keep the same reward-to-risk ratio. Pick one, test it, and do not switch between them trade by trade.

How many ORB trades should I take per day?

The cleanest rule is one long attempt and one short attempt, with a cut-off time after which no new trades are taken. Allowing unlimited re-entries turns the strategy into a general breakout scalper and multiplies your exposure to choppy days.

Is an ORB indicator the same as an ORB strategy?

No. An indicator draws the range and marks the breakouts; it has no position sizing, no exits and no equity curve. A strategy script adds entries, stops, targets and fills, and can be run through a strategy tester. The indicator above is the first step; the strategy is the second.

Can an ORB strategy pass a prop firm evaluation?

It can be made compatible with typical prop firm rules because it has a defined stop and a defined session, which makes daily loss limits easy to respect. Whether a particular ORB system is profitable enough and consistent enough to pass a specific firm's rules is something no article can tell you; it depends on the instrument, the parameters and the firm's rule set.

Where Viprasol fits

Viprasol builds trading tools for individual traders and small firms: TradingView indicators and strategies in Pine Script v6, MT5 expert advisors in MQL5, and the webhook infrastructure to connect the two to a broker. For ORB specifically we deliver the indicator with session presets and filters, a strategy version with cost-aware backtesting, and if you want it automated, a prop-firm-compliant EA with daily loss guards built in. Free utilities, including a position size calculator that mirrors the arithmetic in the worked example, are on the tools page. Pricing is listed on the pricing page and you can describe your rule set through the contact form.

Risk disclaimer: trading futures, forex, CFDs and crypto involves substantial risk of loss. This article is educational and is not investment advice; past backtest results do not indicate future performance.

orb trading strategyopening range breakout strategy15 minute orb strategyorb indicatorpine scriptday tradingbreakout trading

External Resources

Share this article:

About the Author

V

Viprasol Tech Team

Custom Software Development Specialists

The Viprasol Tech team specialises in algorithmic trading software, AI agent systems, and SaaS development. With 1000+ projects delivered across MT4/MT5 EAs, fintech platforms, and production AI systems, the team brings deep technical experience to every engagement.

MT4/MT5 EA DevelopmentAI Agent SystemsSaaS DevelopmentAlgorithmic Trading

Ready to Automate Your Trading?

Discuss a custom Expert Advisor with defined strategy rules, risk controls and a testing plan.

Free consultation • No commitment • Response within 24 hours

Viprasol · Trading Software

Need a custom EA or trading bot built?

We build MT4/MT5 Expert Advisors around your strategy, broker and risk requirements. Each project has an agreed scope, testing plan and individual quote.