Scripts / Session Range (Opening Range)
Session Range (Opening Range)
Free (planned) IndicatorMarks a user-defined session on the chart. The default is the first 30 minutes of the US cash equity session (09:30–10:00 America/New_York). While that session is open, the script tracks the session high and low. After the session ends, those levels are frozen. Later closes can be marked, and can fire alerts, when they break above or below the range. A midpoint and range-width extensions are optional.
Free access is planned. On this preview the source is here so you can paste it into TradingView and confirm it compiles. Nothing has been published to TradingView or to the live domain.
What it does
Marks a user-defined session on the chart. The default is the first 30 minutes of the US cash equity session (09:30–10:00 America/New_York). While that session is open, the script tracks the session high and low. After the session ends, those levels are frozen. Later closes can be marked, and can fire alerts, when they break above or below the range. A midpoint and range-width extensions are optional.
Use a timeframe shorter than the session length. A 1-minute or 5-minute chart is a typical choice for a 30-minute range. For a crypto first-hour range, change the session (for example 0000-0100) and the timezone (for example Etc/UTC).
Settings
| Opening-range session | Default 09:30–10:00, in HHmm-HHmm format. |
|---|---|
| Timezone | Default America/New_York. Other common zones are listed, plus “Chart timezone.” |
| Wait for the bar to close | On by default. A break is only marked after the candle confirms. |
| Midpoint and extensions | Midpoint on by default. Optional extensions at 0.5× and 1.0× the range width. |
| History | Prior sessions can stay on the chart, with a cap (default 20). |
| Labels, table, alerts | First-break labels, a status table, and alerts for range complete / close above / close below. |
How to add it in TradingView
- Open TradingView on a chart whose timeframe is shorter than the session you want (for the default 30-minute US range, 1-minute or 5-minute is typical).
- Open the Pine Editor at the bottom of the window.
- Copy the source file session_range.pine, paste it into the editor (replace whatever is there), then Save and Add to chart.
- Set the session and timezone in Settings to match the market you are watching.
- Leave “Wait for the bar to close before marking a break” on so a break is only marked after the candle confirms.
- Optional: create an alert and pick “Opening range is complete,” “Close above the opening range,” or “Close below the opening range.”
Notes, including backtests
This is an indicator, not a strategy, so it has no Strategy Tester results to report. It has had a careful manual review for Pine Script v6, but it has not been compiled in TradingView yet. After you paste it, if TradingView shows an error, copy the exact message and the script can be fixed before anything is published.