Opening Range Breakout in Pine Script
The high and low of the first minutes of a session, on the exchange clock, and the first close beyond either edge as the day's directional trigger.
Definition
An opening range breakout (ORB) takes the high and low of the first part of a session, typically 15 or 30 minutes, and trades the first move through either edge. It belongs to the session ranges family: tools that build a level from a window of the trading day and read the rest of the day against it. The window is defined on the exchange's clock. A 09:30 to 10:00 range for a US stock is the first half hour of the cash session, whatever time zone the trader sits in, and it shifts with the exchange's daylight saving.
The range works because the open is where the day's information is priced. Overnight news, pre-market orders and the first institutional flow all meet in the opening minutes, and the extremes of that auction are the levels where the two sides first agreed to stop. A close beyond the range shows one side has absorbed the other's opening position and is willing to pay up for more. Days that leave the opening range early and do not return tend to be the trend days, and the ORB is a systematic way to be on board for them.
The method was set out by Toby Crabel in his 1990 work on short-term price patterns, and later frameworks built more elaborate rules on the same range. The standard windows are 5, 15, 30 and 60 minutes after the open, with 30 the most common for stocks and index futures. The implementations here use a session input in exchange time, 0930-1000 by default. They draw the range once the window has closed and mark the first close above the high and the first close below the low each day. The strategy version takes one trade per day, stops at the range's other side and goes flat before the close.
On the chart, expect the window to be shaded, the range lines to appear only after the window ends, and one mark per direction per day from the indicator. Expect a wide opening range on news days to make the breakout distance large and the stop distance larger, and a narrow range on quiet days to produce breakouts that fail and return. Expect most of the results to come from a minority of days that trend from the open. The method's results depend on holding those days rather than on the win rate of the breakouts themselves.
Reading the chart
The range is defined by the clock before any price is read, so identification starts with the session and the window.
- Find the session open on the exchange clock, not on your own. US equities open at 09:30 New York time; a London-listed share opens at 08:00 London time. The window is measured from that open.
- Choose the window length. 30 minutes is the common default for stocks and index futures; 15 minutes suits faster markets, and 60 gives a wider, slower range with fewer false breaks.
- Record the highest high and lowest low printed inside the window. The range only exists once the window has closed; nothing traded after it changes the levels for that day.
- Wait for a close outside the range. A bar that pokes through and closes back inside is a failed break under the close rule, and the day's first real signal is still to come.
- The rule trades the first close beyond an edge in that direction, with the stop at the opposite edge. The range height is the initial risk, and targets are commonly set at one or two range heights.
- The rule closes before the session ends. The trade is a bet on the day's direction, and holding it overnight turns it into a different trade with gap risk the method never tested.
The maths
The range is the extreme of the window's bars, and the signals are closes compared with those extremes after the window.
The window runs on the exchange clock through the symbol's time zone, never GMT, so a 0930-1000 window follows the exchange through daylight saving changes without editing.
The window must be a multiple of the chart timeframe. On a 5-minute chart a 30-minute window is 6 bars; on a 1-hour chart the same window is one bar that ends at 10:30, so the range is really the first hour.
The indicator marks one long and one short per day at most, and both can occur on the same day. The strategy takes only the first break of either side and then stays out until the next session.
The range resets on the daily change of the chart's symbol. On markets whose session crosses midnight, check where the platform's day boundary falls before trusting the reset.
Inputs that matter
| Input | Typical | What changing it does |
|---|---|---|
| Opening window (exchange time) | 0930-1000 | A longer window gives a wider range with fewer false breaks and later entries; a shorter one gives earlier entries and more failed breakouts. Type it as exchange-clock times. |
| Flat at hour and minute (strategy) | 15:55 exchange time | The time the strategy closes any open position, matched to a bar's open time within that hour. 15:55 needs 1 or 5-minute bars; on 15-minute bars set 15:45, since no bar opens at 15:55. |
| Trade longs and Trade shorts (strategy) | both on | Restricting to one side turns the strategy into a directional filter, useful when a higher-timeframe read favours one side. |
| Target | none in the implementation | Adding a target of one or two range heights caps the winners but raises the win rate; without one, trend days carry the results. |
In practice
- As the day's directional trigger: the rule takes the first close outside the range in that direction, stops at the other edge, and holds for the rest of the session.
- As a trend-day detector: a break within the first hour that never returns to the range is the signature of a trend day, and the ORB is how a trader is positioned for it without predicting it.
- As a level set for the session: the range's high and low remain reference levels all day, and a return to the broken edge after the breakout is the standard second-entry point.
- As a filter on other setups: an intraday pullback entry taken only on the side of the opening range breakout aligns the trade with the day's direction.
- As a session-specific tool: a London breakout uses the same logic with a window such as 0800-0900 London time, and an Asian range build uses a longer overnight window as the box.
- As a backtest: the strategy implementation takes one trade per day with a range-edge stop and a timed exit, which is a clean baseline to which volume filters, targets or a trend filter can be added.
Where it goes wrong
- Defining the window in the wrong clock. A range built on the trader's local time or on GMT drifts with daylight saving and misses the real open; use exchange time, as the implementations do.
- Trading every break in both directions. A wide range on a news day can be broken both ways; the strategy's one trade per day is deliberate, and the second break is usually the worse one.
- Ignoring the range height. A very narrow range produces cheap stops and frequent failures, and a very wide one produces stops too large for the account; compare the range with the average daily range before trading.
- Holding past the close. The method was measured inside the session, and an overnight hold adds gap risk that the range never measured.
Compared with
Breakout. A generic breakout is measured against any range or channel; an opening range breakout uses one specific range, built from a clock-defined window at the open, and it resets every session. The clock, not the price history, defines the level.
Previous Day High & Low. The previous day's high and low are levels from the whole prior session, known before the open. The opening range is built during the current session's first minutes, so it captures today's positioning rather than yesterday's.
Time-of-Day Windows. A time-of-day window only says whether the current bar is inside a chosen period. The opening range uses such a window to build a price level and then trades the break of it, so the window is the input and the range is the output.
Donchian Channels. A Donchian channel is the extreme of a rolling number of bars and moves every bar. The opening range is the extreme of a fixed window and stays put for the session, so its break has a fixed reference and a fixed risk.
Build it in Quant
Type one of these in the Quant desk, or click it. A request that fits a checked template is assembled on the spot without a credit; anything beyond the blanks goes to the copilot, which edits on top of the checked script.
Questions
How long should the opening range be?
30 minutes is the common default for stocks and index futures, and it is the implementation's default window of 0930-1000. 15 minutes gives earlier entries with more false breaks and suits fast markets; 60 minutes gives a wider, steadier range at the cost of a later entry and a bigger stop. Test the choice on the market's own history.
Which time zone does the window use?
The exchange's. The implementations pass the symbol's own time zone to the session function, so 0930-1000 means 09:30 to 10:00 in New York for a US stock and follows the exchange through daylight saving. Never convert the window to GMT; type the times as the exchange's clock reads them, for example 0800-0900 for the London open.
What does the indicator mark?
Once the window has closed it draws the range high and low as lines and shades the window. It marks Long on the first close above the range high and Short on the first close below the range low, at most once each per day, on confirmed bars. Both marks can appear on one day if the range is broken both ways.
How does the strategy version trade?
One trade per day. It enters long on the first close above the range or short on the first close below it, whichever comes first, with the stop at the range's other edge. It closes any position at the flat time, 15:55 exchange time by default, and has no target. The flat time is matched to a bar's open time in that hour, so 15:55 needs 1 or 5-minute bars; on 15-minute bars use 15:45.
Why is there no mark on my hourly chart?
Because the window is smaller than the bar. A 0930-1000 window on a 1-hour chart covers part of a single bar, so the range and the break blur together. Use a chart timeframe that divides the window: 1, 5 or 15 minutes for a 30-minute range. The implementations are intraday tools by design.
Does the ORB work on crypto or FX?
The logic transfers, but the open has to be chosen, since those markets trade around the clock. Common choices are the London or New York cash open for FX and the daily candle open for crypto, typed as a window in the exchange's own clock. Without a real open, the range is arbitrary and the method is weaker.