Opening range
All plugins

Plugin librarySessions and time

Plugin

Opening range

The high and low of the first minutes after a market opens, its size in daily ATR and where price is now, never before the window has closed.

IndicatorNo networkDesktop onlyv1.0.0

About

The opening range is the high and low of the first minutes after a market opens: 30 minutes after 09:30 New York for US stocks and index futures, or after 09:00 Frankfurt for the DAX. Breakout traders buy above it or sell below it, and many skip days where the range is already wide compared with a normal day. This indicator gives a strategy the range, its middle, its size in units of a daily ATR, whether the close is above, inside or below it, and the range of the first hour beside it.

Nothing is reported before the window has closed, so a backtest can never trade on a range that was still forming. The open is a wall clock time in a time zone, so 09:30 New York stays 09:30 New York when the clocks change. The window starts again every local day; after local midnight the outputs are None until the new window closes.

Parameters

NameTypeDefaultRange or optionsDescription
opentext"09:30"The opening time on the clock of tz.
tztext"America/New_York"A time zone name (IANA), like Europe/Berlin or America/New_York.
minutesint30min 1, max 1440The length of the window; it must end by local midnight.
atr_periodint14min 1, max 200Finished local days in the daily ATR (Wilder's smoothing).

Use it in a strategy

pythonorb = ctx.plugin_indicator("opening_range", "range", {"open": "09:30", "tz": "America/New_York", "minutes": 30})
if orb is not None and orb.complete and orb.size_atr is not None and orb.size_atr < 0.5:
    if orb.position == 1:
        ctx.signal("LONG")
    elif orb.position == -1:
        ctx.signal("SHORT")

The indicator library has this as opening_range: ctx.ind("opening_range", zone="new_york", hour=9, minute=30, minutes=30) reads it, on the clock of UTC, London, New York, Tokyo or Sydney, and the chart, Blocks, Rust and the Rust core have it too. This template stays as an example of a plugin indicator; only it takes any time zone and has the first hour range.

What it provides

high, low, midValueThe range of the bars that start inside the window, and its middle (also value); None until the window has closed.
completeValueTrue from the bar that closes the window until local midnight.
size, size_atrValuehigh - low, and that size divided by the daily ATR; size_atr is None until the ATR has warmed up.
positionValue1 when the bar's close is above the range, -1 below it, 0 inside; None until the window has closed.
hour_high, hour_lowValueThe range of the first 60 minutes after the open, by the same rules.
atrValueWilder's ATR of finished local days in tz, never today; None until atr_period + 1 days have finished.

Limits

  • A bar belongs to the window when it starts inside it. Use a timeframe that lines up with the open and is no longer than the window (M1, M5, M15 or M30 for 09:30); with H1 bars a 09:30 window has no bar and stays None.
  • Holidays and half days are not known: a day without bars in the window has no range, a day with bars has one, whatever the exchange did that day. With round the clock data (forex, crypto) the window is cut from those bars.
  • A plugin indicator is not drawn on the chart and is not available in Blocks, Pine, Rust or C#; it runs on the run's own instrument only.
OrionQuant