Opening range
All indicators

LibraryTime

Indicator

Opening range

The high and low of the first minutes after a market opens, the range's middle and size, the size against a daily ATR, and where the close is against the range.

TimeOn the price5 inputsOR

How it is calculated

The window runs from the open (hour and minute on the chosen clock, daylight saving included) for the set minutes, cut at local midnight, every local day. High and low are those of the bars that start inside it; mid is their mean, size their difference. size_atr is size divided by Wilder's ATR over the finished local days. position is 1 above the high, -1 below the low, 0 inside.

Reference: Opening range (Crabel 1990), on the zone's wall clock

How to read it

Nothing shows until the window has closed, at the close of the bar that reaches its end, so a strategy never acts on a range still forming; from local midnight it is empty again until the next window closes. A bar counts when it starts inside, so a 09:30 window needs M30 or finer. Frankfurt's 09:00 is 08:00 London, the same instant all year.

In a strategy

An opening range breakout: with r = ctx.ind("opening_range", zone="new_york", hour=9, minute=30, minutes=30) go long when r.position turns 1 and short when it turns -1, skipping days where r.size_atr is above 0.5.

Inputs

InputTypeDefaultRange or choices
ClockzoneChoice"new_york"UTC, London, New York, Tokyo, Sydney
Open hourhourWhole number9min 0, max 23
Open minuteminuteWhole number30min 0, max 59
Range minutesminutesWhole number30min 1, max 1440
ATR daysatr_lengthWhole number14min 1, max 200

What it draws

LineDrawn as
Range highSteps
Range lowSteps
Range middleSteps

Used in

No strategy template reads it yet.

OrionQuant