OPEN-SOURCE SCRIPT
更新済

RPFXBYDAN - Multi-Session Range & Pre-Market Highlighter

690
# Multi-Session Range & Pre-Market Highlighter

An educational visualization tool that automatically highlights three key intraday time windows for the New York, London, or Tokyo sessions: a pre-market window ahead of the exchange open, a short opening range around the open, and the regular trading session that follows. Designed to help chart readers see how price behaves across these fixed time blocks each day.

This script does not generate trade advice, does not predict future price movement, and does not backtest a strategy. It is a visualization overlay that draws boxes and reference levels based purely on session time and the price action of the current chart.

## What It Displays

The indicator identifies and marks three distinct intraday windows in the timezone of the selected market:

1. **Pre-Market Window** — A short block of time ahead of the exchange open. By default this is a 15-minute window starting 1.5 hours before the trading session begins. The high and low across this window are recorded and drawn as a translucent box with optional dashed reference lines.

2. **Opening Range Window** — The 15 minutes immediately before the regular trading session begins. During this window, the indicator records the highest high and lowest low. When the window ends, those two prices are locked and drawn as horizontal reference levels for the rest of the day.

3. **Trading Session** — The regular exchange hours. During this window, the indicator continues to display the locked reference levels from the opening range and observes when price crosses above the upper level or below the lower level. Cross events are marked on the chart with small directional markers.

All three windows reset automatically at the start of each new trading day.

## How Reference Levels Are Formed

For each new trading day, the indicator tracks the highest high and lowest low of every bar within the opening range window. When the window closes, these two prices become that day's fixed reference levels. They remain drawn on the chart through the rest of the session so the viewer can see the day's early range relative to subsequent price action.

The pre-market window works the same way independently — its own high and low are recorded and shown, giving context for how the market moved into the open.

## Cross Events

Once the opening range levels are locked and the trading session is open, the indicator observes when the current bar crosses above the upper reference level or below the lower reference level. The trigger can be configured to any of the following:

- **Close** — Requires a bar to close beyond the level.
- **High / Low** — Any intrabar high or low print beyond the level triggers.

An optional **retest confirmation** filter can also be enabled: after an initial cross, a return to the level and a re-cross in the same direction is required before the event is marked. A limit of one event per direction per day can also be enabled to keep the chart clean.

Cross events are informational only — they mark where price interacted with the reference level. They are not trade signals and do not constitute a recommendation to buy, sell, hold, or take any action.

## Built-in Session Presets

Selecting a Market applies the standard hours for that exchange, evaluated in the exchange's own timezone (so it works correctly regardless of your chart's timezone):

- **New York (NYSE/NASDAQ)** — Opening Range 09:15-09:30, Trading 09:30-16:00 America/New_York
- **London (LSE)** — Opening Range 07:45-08:00, Trading 08:00-16:30 Europe/London
- **Tokyo (TSE)** — Opening Range 08:45-09:00, Trading 09:00-15:00 Asia/Tokyo

Every default can be overridden with custom session strings for non-standard schedules (half-days, futures pit hours, FX-overlap windows, etc.).

## Settings

- **Market & Sessions** — Market selector, "Use Market Defaults" toggle, custom Opening Range and Trading Session strings, and a fine-grained Opening-Range Start Offset control that nudges only the OR start time in 1-minute steps.
- **Your Local Timezone** — Display-only. Controls the timezone shown in the local column of the info table. Does not affect any calculations.
- **Signal Logic** — (This group controls the cross-event trigger.) Choose trigger source (Close vs High/Low), enable the retest filter, set the retest window, and toggle the one-event-per-side-per-day cap.
- **Pre-Market Marker** — Enable/disable, minutes before exchange open, window length, and style controls.
- **Visuals** — Toggles and color/width controls for the opening range box, reference lines, midline, on-chart markers, and info table.

## Info Panel

An optional info panel in the top-right corner of the chart shows the selected market, both timezones, and the resolved time window for each of the three windows in both the exchange timezone and your local timezone.

## Alerts

The indicator provides three alert conditions:

- **Range High Break** — Fires when price crosses above the locked upper reference level (after the OR window has closed).
- **Range Low Break** — Fires when price crosses below the locked lower reference level (after the OR window has closed).
- **Opening Range Locked** — Fires at the moment the opening range window ends and the reference levels are finalized for the day.

## Timeframes and Instruments

The indicator is designed for intraday timeframes (1-minute through 15-minute typically works best). It is compatible with any instrument that has intraday data, including stocks, futures, indices, forex, and crypto. Non-standard trading hours can be handled by disabling defaults and typing custom session strings.

## Educational Notes on the Opening Range Concept

The opening range is a well-known chart-reading concept: the high and low of a fixed early portion of the trading day. Many chart readers use these levels as visual reference points for evaluating subsequent price action. This indicator does not endorse or recommend any particular way of using them — it simply draws the levels consistently and lets the viewer study them.

## Disclaimer

This script is provided for educational and informational purposes only. It is a visualization tool that highlights configurable price windows on the chart; it is not a trading system, is not trading advice, and does not constitute a recommendation to buy, sell, hold, or take any other action with respect to any instrument. Trading and investing carry substantial risk of loss. Past price behavior is not indicative of future results. You are solely responsible for any decisions you make based on what you see on your chart. Always do your own research and consider consulting a licensed financial professional before making any trading or investment decisions.
リリースノート
Update — Nearest Pre-OR Breach Lines

Added a new "Nearest Pre-OR Breach" feature that identifies the closest pre-Opening-Range candles that pierced the OR High and OR Low, and draws them as dashed horizontal reference lines.

Key behavior:

Dynamic tracking during OR formation — as the OR High and OR Low update on each bar of the opening range, the scan re-runs and the reference lines shift to the appropriate reference candle in real time. If no prior candle in the lookback window exceeds the current OR bounds on a given side, that line is automatically removed.

Line anchoring — each dashed line starts at the timestamp of the reference candle itself (so you can see exactly which candle it's marking) and ends 5 minutes after the Trading Session open. No infinite extension.

Configurable — Max Lookback (minutes) controls how far back to search (default 240 = 4 hours). Separate color pickers for the upper and lower reference lines, plus a shared line-width control.

Info-table row added showing the two captured price levels, or a dash if no breach was found within the lookback window.

免責事項

これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。