OPEN-SOURCE SCRIPT
Diupdate

IB/ORB Statistical Mapper (hardcoded)

2 418
# IB / ORB Live Stats — Publication Description

---

## What This Indicator Does

The **IB / ORB Live Stats** indicator studies the relationship between the **Initial Balance (IB)** and a user-defined **Opening Range Breakout (ORB)** window, and builds its probability statistics **live, from the history on your own chart** — there are no pre-supplied or hard-coded numbers anywhere in this script. Every percentage you see is computed from the completed sessions visible on the current symbol and timeframe, so the statistics describe exactly the instrument you are looking at.

Rather than issuing buy/sell signals, the indicator answers structural questions about how each session tends to behave:

- When the IB **high** forms before the IB **low**, which side tends to **break first** afterward — and vice versa?
- Does the side that formed first also tend to break first (a continuation tendency), or reverse?
- Do these tendencies change when the range is unusually **wide** or **narrow**?
- When the ORB closes bullish or bearish, how often does the IB end up bullish or bearish?

It draws a box and midpoint for both the IB and the ORB, and presents two independent, separately-configurable statistics tables — one for the IB, one for the ORB.

---

## Core Concepts and Definitions

Before the statistics make sense, it helps to define each term precisely as the script uses it.

### Initial Balance (IB)
The price range established during the IB window (default **09:30–10:30 ET**). The IB high is the highest traded price and the IB low the lowest traded price during that hour. The IB midpoint is the average of the two.

### Opening Range Breakout (ORB)
A shorter range measured from the open. You set its length in **minutes** (default **15**), and the script builds the corresponding session window automatically. The ORB high, low and midpoint are defined the same way as the IB's.

### Formed First (the order of the extremes)
For each window, "formed first" identifies whether the session **high** or the session **low** was reached **earlier in time**. This is the single most important measurement in the script, and it is deliberately **not** judged from chart bars. A single chart candle frequently contains both the session high and the session low, which makes any bar-by-bar guess unreliable. Instead, the script requests **1-minute intrabar data** and walks those sub-bars in chronological order: the first 1-minute bar whose high reaches the final session high, versus the first whose low reaches the final session low — whichever comes earlier is the extreme that "formed first."

### Broke First (the order of the breakouts)
Once a window's formation period closes, the script watches for price to trade **beyond** that window's high or low. "Broke first" records which side was exceeded **first** during the rest of the regular session. Like formed-first, this uses the 1-minute intrabar feed so a large chart candle cannot hide the true sequence. If neither side is exceeded before the regular session ends, broke-first is recorded as **"none" (Neither)**.

### Direction (Bullish / Bearish / Neutral)
A single composite read of the window, combining where it formed first with where it closed:

- **Bullish** — the **low** formed first **and** the window closed in its **upper** half.
- **Bearish** — the **high** formed first **and** the window closed in its **lower** half.
- **Neutral** — every other combination (mixed signals).

The same definition is applied to both the IB and the ORB so the two can be compared like-for-like.

### Range Size: Narrow / Normal / Wide
Each window's range (high minus low) is classified **relative to its own prior history on the chart**. The classification is computed **before** the current session is added to the history, so "Wide" genuinely means wide relative to the past, not relative to a sample that already includes today. Two methods are available:

- **Z-Score** — today's range is expressed as a number of standard deviations from the historical mean. A range at or below `−Z band` is **Narrow**; at or above `+Z band` is **Wide**; in between is **Normal**.
- **Percentile** — today's range is ranked against history. At or below the Narrow percentile cutoff it is **Narrow**; at or above the Wide cutoff it is **Wide**; in between is **Normal**.

---

## The Statistics Tables, Explained Line by Line

There are two tables — **IB LIVE STATS** and **ORB LIVE STATS** — each with the same structure. The ORB table adds one extra section (the ORB-to-IB contingency) at the bottom.

### Top block — today's live readout

- **Formed first** — for the current session: `HIGH`, `LOW`, `pending` (window not yet complete), or `—` (could not be resolved, e.g. no intrabar data).
- **Broke first** — `HIGH`, `LOW`, `pending` (window not complete), `watching…` (window complete, no break yet this session), or `none` (session ended with no break).
- **Range** — today's range value, followed where available by its z-score (`z=`) and its percentile rank (`%`) against history.
- **Type** — the Narrow / Normal / Wide classification of today's range.
- **Direction** — today's Bullish / Bearish / Neutral composite.

### Cross-tabulation block — the formed-first by broke-first matrix

This is the heart of the tool. It answers: *given which extreme formed first, which side then broke first?* The columns are **BrkH** (broke high first), **BrkL** (broke low first) and **Neither**. There are two rows:

- **HIGH (n)** — all completed sessions where the **high** formed first. The three percentages show how often, within those sessions, the high broke first, the low broke first, or neither side broke. `n` is the number of such sessions.
- **LOW (n)** — the same, for sessions where the **low** formed first.

Each row sums to 100% across its three columns. Reading across the HIGH row tells you, when the high formed first, whether the market tends to continue up (BrkH) or reverse down (BrkL).

- **Same side broke 1st** — a single summary figure: across **all** completed sessions, how often the side that formed first was also the side that broke first. This is the overall **continuation tendency**; a high value means formed-first tends to predict broke-first, a low value means the market tends to reverse the early extreme.

### BY SIZE block — does range size change behavior?

This block splits every completed session into its size bucket and reports, per bucket:

- **Size** — Narrow, Normal or Wide. The bucket matching **today's** session is highlighted.
- **n** — number of completed sessions in that bucket.
- **Brk%** — of those sessions, how often **any** side broke (i.e. the session was not a "Neither" day).
- **Cont%** — of those sessions, how often the side that formed first also broke first (the continuation tendency, but isolated to that size bucket).

This is where the size classification earns its place: you can see directly whether, say, Wide ranges break and continue more often than Narrow ones.

### ORB-to-IB contingency block (ORB table only)

This answers how the early ORB read relates to the later IB outcome. It is a small matrix with the columns **IB Bull**, **IB Bear** and **IB Neut**, and two rows:

- **Bullish (n)** — all completed days where the **ORB** direction was Bullish. The three percentages show how the **IB** direction turned out on those days. `n` is the count.
- **Bearish (n)** — the same, for days where the ORB direction was Bearish.

Each row sums to 100%. The Bullish row directly answers "when the ORB is bullish, how often is the IB also bullish, bearish, or neutral?"

### The "Min sample" dimming rule

Any percentage drawn from fewer completed days than the **Min sample** input is shown in grey rather than its normal colour. This is a guard against over-reading thin data — a 100% figure from 2 sessions is meaningless, and the dimming makes that visually obvious while still letting the count build.

---

## How To Use This Indicator

### Recommended setup
Run it on a **1-minute chart** for the most accurate formed-first and broke-first detection. A 5-minute chart is the practical maximum; on higher timeframes the 1-minute intrabar window loses resolution and the ordering of extremes becomes less reliable. Make sure your chart has enough history loaded — the statistics only accumulate from sessions actually present on the chart, so a fresh chart starts empty and fills in over days of scrolled-back or elapsed history.

### A typical workflow
1. **Let it build.** The longer the history on the chart, the larger every `n`. Figures stay greyed out until they pass the Min sample threshold.
2. **Read the cross-tab.** In the IB table, look at the HIGH and LOW rows to see whether the first extreme tends to lead to continuation or reversal on your instrument.
3. **Check the size split.** In the BY SIZE block, compare Brk% and Cont% across Narrow / Normal / Wide to see whether range size meaningfully changes behavior. Today's bucket is highlighted for quick reference.
4. **Use the ORB-to-IB contingency** to gauge whether the early ORB direction is informative about how the IB resolves.
5. **Combine with your own analysis.** These figures are descriptive context, not signals.

---

## Inputs and Configuration

Every input is listed below with its default and its effect.

### Sessions group
- **IB Period (ET)** — the Initial Balance window. Default `0930-1030`.
- **ORB Period (minutes from 09:30)** — the ORB length in minutes. Default `15`, range `1–120`. The script builds the actual session window from this (e.g. 15 → 09:30–09:45) so you never edit a session string for the ORB.
- **RTH (ET)** — the regular trading hours window during which breaks are tracked and after which each day's outcome is recorded. Default `0930-1600`.
- **Intrabar resolution** — the lower timeframe used for first-touch detection. Default `1` (one minute). This must be at or below your chart timeframe; one minute is strongly recommended.

### IB/ORB Type group
- **Size method** — `Z-Score` or `Percentile`, selecting how Narrow / Normal / Wide is decided. Default `Z-Score`.
- **Z band (Narrow<=-z, Wide>=+z)** — the z-score threshold used by the Z-Score method. Default `0.5`. A range at or below −0.5 SD is Narrow, at or above +0.5 SD is Wide.
- **Narrow <= percentile** — the percentile cutoff for Narrow when using the Percentile method. Default `33`.
- **Wide >= percentile** — the percentile cutoff for Wide when using the Percentile method. Default `67`.

### Display group
- **Show IB (box)** — draw the IB box and midpoint. Default on.
- **Show ORB (box)** — draw the ORB box and midpoint. Default on.
- **Show NY Open Line** — draw a vertical line at the regular-session open. Default on.
- **Box Transparency** — transparency of the box fills, `50–95`. Default `88` (higher is more transparent).
- **IB / ORB / NY Line colours** — colour pickers for each element.

### Tables group
- **Show IB Table** — master toggle for the IB statistics table. Default on.
- **IB Position** — one of nine on-chart positions for the IB table. Default Top Right.
- **IB Text Size** — Tiny / Small / Normal / Large. Default Tiny.
- **Show ORB Table** — master toggle for the ORB statistics table. Default on.
- **ORB Position** — nine-position selector for the ORB table. Default Top Left.
- **ORB Text Size** — Tiny / Small / Normal / Large. Default Tiny.
- **Min sample (dim below)** — the minimum number of completed days a percentage must be based on before it is shown in full colour rather than grey. Default `30`, range `5–200`.

---

## How the Calculations Work (methodology)

All statistics are computed on-chart, in real time, with no external data:

1. **During each window**, the script accumulates the running high and low and collects every 1-minute sub-bar's high and low.
2. **At window close (seal)**, it walks the collected 1-minute bars in order to determine which extreme was reached first, classifies the range size against prior history, computes the composite direction, and freezes the box and midpoint at the closing bar.
3. **After the window, through the regular session (watch)**, it scans the 1-minute feed for the first break of either side and records broke-first.
4. **At the regular-session close (tally)**, it increments the cumulative counters — the formed-first by broke-first cross-tab, the size buckets, and (for the ORB) the ORB-to-IB direction contingency — so each completed day is counted exactly once.

The boxes and midpoints are **frozen** at each window's close; they do not extend across the day.

---

## Important Limitations and Considerations

1. **History-dependent.** All statistics come only from sessions present on your chart. A fresh chart has no sample; figures grow over time and stay greyed until they pass the Min sample threshold. The depth of history TradingView loads depends on your plan and the chart timeframe.
2. **Intrabar accuracy.** Formed-first and broke-first rely on the 1-minute feed and are most accurate at or below 5-minute chart resolution. On higher timeframes the ordering can be wrong.
3. **Same-sub-bar ties.** If a single 1-minute bar contains both a new extreme and a break of the opposite side simultaneously, the tie is resolved in favour of the high. This is rare but worth knowing.
4. **Descriptive, not predictive.** The indicator reports what has happened on your data. It does not forecast, and it issues no signals. Past frequency does not guarantee future behavior — a 70% tendency still failed 30% of the time.
5. **Not financial advice.** Use these statistics as objective context alongside your own strategy and risk management, never as a substitute for judgement.

---

*This is an analytical and educational tool. It does not provide buy or sell signals and makes no claim about future price direction.*
Catatan Rilis
Corrected a bug with the logic that tracks if the high or low forms first

Pernyataan Penyangkalan

Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.