OPEN-SOURCE SCRIPT
מעודכן

Opening Range Box

1 078
Opening Range Box

Opening Range Box highlights the high and low of a user-defined opening session and visualizes the range directly on the chart. The script tracks price during the selected session window and dynamically builds a range using the highest high and lowest low that occur within that period. As the session progresses, the range updates in real time so traders can see the developing structure of the opening market activity.

Once the session begins, the indicator starts calculating the opening range and draws a box around the price action between the session high and low. At the same time, horizontal lines are plotted at the high and low levels of the range. These levels represent important reference points that many intraday traders use to identify potential breakout, breakdown, or support and resistance zones.

After the opening session ends, the final range is locked in. If enabled, the high and low levels can automatically extend to the right side of the chart so they remain visible for the rest of the trading session. This allows traders to easily monitor how price interacts with the opening range throughout the day.

An optional midpoint line can also be displayed. This dashed line represents the 50% level of the opening range and can be used as an additional reference level for balance, mean reversion, or intraday bias.

All visual elements can be customized. Users can control the session time, enable or disable the range box, show or hide the midpoint, extend the range levels across the chart, and adjust colors and line width to match their chart layout.

The default session is set to 09:30–10:00 to match the first thirty minutes of the U.S. equities market open, but it can be changed to any time window to suit different markets or trading strategies. The indicator is designed for intraday charts and is commonly used for opening range breakout strategies and early-session support and resistance analysis.
הערות שחרור
Updated
הערות שחרור
Updated with option to show historical orbs.
הערות שחרור
Updated with Historical Lookback feature.
הערות שחרור
Added Midline Style functionality.
הערות שחרור
Added break of range labels.
הערות שחרור
Added reverse signals/logic.
Added non-repaint user control/logic.
הערות שחרור
Added custom ATR target lines.
הערות שחרור
Historical ORB behavior updated.
הערות שחרור
Internal adjustments.
הערות שחרור
Pine category updated.
הערות שחרור
Here's what changed between the original and the current version:

---

**Settings Panel Organization**

The original had all settings dumped in one flat list with no grouping. The current version organizes everything into labeled sections — Session, ORB Display, ORB Style, ATR Lines, and Break Labels — so related settings are visually grouped together in the indicator's settings panel. Every single input also has a tooltip, meaning if you hover over a setting you get a plain-English explanation of what it does.

---

**Separate Line Width Controls**

The original had one single "Line Width" knob that applied to everything — the box, the green/red/mid lines, and all the orange ATR lines. The current version splits this into two independent controls. "ORB Line Width" governs the box border, the green high line, the red low line, and the midline. "ATR Line Width" governs only the orange ATR target lines. This lets you make the ORB itself visually bold while keeping the ATR lines thinner (or vice versa).

---

**Default Changes**

Three defaults were updated. Show Historical ORBs flipped from off to on, so prior sessions are visible immediately without having to dig into settings. ORB Line Width defaults to 2 instead of 1, giving the range box and its lines a slightly heavier appearance out of the box. Historical ORBs to Show remains at 2.
הערות שחרור
Break label logic updated.
Added break label style controls.
הערות שחרור
**Opening Range XL — Change Log**

---

**Version: Chart Timeframe Mode + Warning System**

---

**New: "Chart" Duration Mode**

The Range Duration input has been converted from a number picker to a dropdown that includes a new "Chart" option. This option is now the first item in the list and the default selection when the indicator is first added to a chart.

- When "Chart" is selected, the ORB spans exactly one bar of whatever timeframe the chart is currently on — a 5-minute chart gives you a 5-minute ORB, a 15-minute chart gives you a 15-minute ORB, and so on
- All existing minute-duration options (1 through 480) remain exactly as before and behave identically to the original script
- Internally, "Chart" mode detects the single bar whose open timestamp matches your configured Start Time and uses that bar's high and low as the range — no duration math involved

---

**New: Timeframe Warning Table**

A warning label is now displayed directly on the chart when the indicator detects it cannot produce reliable data for the current chart timeframe. The warning is rendered as a fixed table element anchored to the screen edge so it never drifts with price.

- In minute-duration mode, the warning fires when the chart timeframe is larger than the selected duration — for example, a 30-minute ORB setting on a 1-hour chart
- In Chart mode, the warning fires when the chart timeframe is Daily (1440 minutes) or higher, where a single-bar ORB is meaningless
- The warning message tells you exactly what the mismatch is, showing both the chart timeframe in minutes and the selected duration in minutes
- When the warning is not active, nothing is shown and the indicator operates silently as normal

---

**New: Warning Label Position Input**

A new input has been added to the **ORB Display** group allowing you to choose where the warning table appears on screen. The six available positions are Top Left, Top Center, Top Right, Bottom Left, Bottom Center, and Bottom Right. The default is Top Right.

---

**New: ORB Suppressed When Warning Is Active**

When the warning is showing, the indicator now draws nothing at all. This is intentional — if the timeframe mismatch means the data would be wrong, displaying it silently would be worse than displaying nothing.

- The ORB box, high line, low line, midline, and all ATR projection lines are blocked from drawing
- Break of range labels are suppressed and will not fire
- If you switch to an invalid timeframe while an ORB is already drawn on screen, all existing drawings are immediately cleared so nothing stale remains visible
- Switching back to a valid timeframe removes the warning and resumes normal drawing immediately
הערות שחרור
**Opening Range XL — What's New**

The updated version is functionally identical to the original in every way that matters for charting — all the opening range box drawing, high/low/midline extensions, ATR projection lines, historical ORB overlays, break-of-range labels, and alerts work exactly as they did before. The only addition is a new on-chart information panel that gives you a quick-glance summary of the session's key settings without having to open the indicator settings menu.

---

**The Info Box**

A compact table now appears on your chart — defaulting to the bottom-left corner — that displays five rows of session and ATR configuration data at a glance:

- **Start** — shows the opening range start time you have configured, such as 0930
- **Range** — shows the range duration setting exactly as you selected it, such as Chart, 5, 15, 30, and so on
- **ATR1** — shows the multiplier value set for ATR Line 1, such as 2
- **ATR2** — shows the multiplier value set for ATR Line 2, such as 4
- **ATR3** — shows the multiplier value set for ATR Line 3, such as 6

The table has a title row at the top that reads "Opening Range XL" and spans the full width of both columns. Below that is a Metric and Value column header row, followed by the five data rows above. Values are color-coded — the start time displays in yellow, the range duration in aqua, and the three ATR multipliers in orange — matching the visual language of the indicator's lines on the chart.

The info box is fully aware of the warning state. If your chart timeframe is too high for the selected ORB duration, the box hides itself automatically, just like the rest of the indicator's drawings do.

---

**New User Inputs — ℹ️ Info Box Group**

All controls for the info box live in their own dedicated settings group at the bottom of the inputs tab. In order from top to bottom:

- **Show Info Box** — a simple on/off toggle to show or hide the panel entirely, defaulting to on
- **Info Box Position** — lets you place the table anywhere on the chart across nine positions: Top Left, Top Center, Top Right, Middle Left, Middle Center, Middle Right, Bottom Left, Bottom Center, or Bottom Right, defaulting to Bottom Left
- **Text Size** — controls the font size of all text inside the table, with options of Tiny, Small, Normal, Large, or Huge, defaulting to Tiny to keep the panel compact and unobtrusive
- **Text Color** — controls the color of the metric label text in the left column, defaulting to a near-white
- **Heading Color** — controls the background color of the title row that reads "Opening Range XL", defaulting to a semi-transparent blue so it stands out clearly from the data rows
- **Background Color** — controls the fill color behind all the data rows, defaulting to a semi-transparent dark background
- **Border Color** — controls the color of the table's outer frame and the dividing lines between cells, defaulting to a semi-transparent gray
הערות שחרור
**What Was Updated**

The info box — the small data table that appears on your chart — now has two display modes you can switch between depending on how much information you want visible at a glance.

**The New "Info Box Mode" Dropdown**

Inside the **ℹ️ Info Box** settings group, directly below the "Show Info Box" toggle, you'll find a new dropdown called **Info Box Mode** with two choices:

- **Detailed** — This is the default and matches exactly what the info box showed before. It displays five rows of data: the session start time, the range duration, and all three ATR multiplier values (ATR1, ATR2, ATR3). Choose this when you want a full at-a-glance summary of your session and target settings.

- **Compact** — Strips the box down to just two rows: start time and range duration. The ATR multiplier rows are completely removed, making the table noticeably smaller. Choose this when you already know your ATR settings cold and just want a quick reminder of the session parameters without the extra visual weight on your chart.

**How to Switch Modes**

1. Open your indicator settings (click the gear icon next to the indicator name on your chart).
2. Navigate to the **ℹ️ Info Box** section.
3. Click the **Info Box Mode** dropdown — it will show `Detailed` by default.
4. Select `Compact` to shrink the box, or leave it on `Detailed` to keep everything visible.
5. Click OK. The info box updates immediately.

That's the entire change — everything else about the indicator behaves identically.
הערות שחרור
**Summary of the Update**

The Info Box in Detailed mode previously displayed all three ATR rows at all times, regardless of whether those ATR lines were actually enabled and drawn on the chart. The update ties the Info Box contents directly to the ATR settings, so the panel now reports only what is genuinely active.

**What the Info Box Did Before**

- Detailed mode always reserved space for three ATR entries.
- Turning off an individual ATR line removed it from the chart but left its multiplier listed in the panel.
- Turning off the master ATR switch removed every ATR line from the chart, yet the panel still listed all three multipliers.
- The result was a readout that could contradict what was visible on screen, showing target levels that were not being plotted.

**What the Info Box Does Now**

- Each ATR entry appears only when two conditions are both met: the master ATR switch is on, and that specific ATR line is switched on.
- Any ATR line that is switched off is fully removed from the panel rather than left displayed.
- Remaining entries move up to fill the space, so no blank or empty rows are left behind where a disabled entry used to sit.
- The panel physically resizes to match its contents, so the border wraps tightly around only the visible rows instead of enclosing unused space at the bottom.

**Behavior in Practice**

- With all three ATR lines enabled, the panel looks and reads exactly as it did before the update.
- With one line disabled, the panel shrinks by a single row and the remaining two entries sit directly beneath the session rows with no gap.
- With the master ATR switch off, the panel reduces to the session start time and range duration only, matching the chart, which shows no ATR levels in that state.
- Compact mode is unaffected. It never displayed ATR information and continues to show only the session start time and range duration.

**Why This Matters**

- The panel now functions as an accurate status readout rather than a static list of settings. What appears in the box always corresponds to what is drawn on the chart.
- Screen space is conserved. Users running one or two ATR targets get a proportionally smaller panel instead of a fixed-size one.
- Misreads are eliminated. There is no longer a scenario where a multiplier is displayed for a level that is not actually being plotted.

**One Consequence Worth Noting**

When the master ATR switch is turned off, Detailed mode and Compact mode produce an identical panel, since the ATR entries were the only difference between them. This is logically consistent, as no ATR information exists to display, but it does mean the mode selector has no visible effect in that particular configuration.

כתב ויתור

המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.