Range Budget [AFD]
Range Budget answers one question at a glance: **how much of a
typical session's range has today already used?**
A day that has spent 40% of its typical range and a day that has spent 130% are different trading environments. This indicator measures which one you are in, from this chart's own price history, and says so in one number, onecolour, and one word.
###What it does###
- **Headline percentage** — today's realized range so far, divided by thetypical completed-session range. Never clamped: a wide day reads 130%, not100%.
- **State word and meter** — ROOM → PAST HALF (50%) → NEAR FULL (80%) → OVER
TYPICAL (100%). The word, the meter and every state colour come from the same thresholds, so they cannot disagree.
- **Envelope levels** — session low + typical range, and session high − typicalrange, drawn as glowing lines with a gradient band between them. Aconditional identity, not a projection: IF the session finishes at itstypical size AND the low holds, the high lands exactly on the upper level. Once the day crosses its typical range, the levels take the state colour.
- **Percentile ladder** (optional) — where a finished day of each size (p25 /p50 / p75 / p90 of the lookback window) would top out, measured up fromtoday's low. Nearest-rank percentiles: every rung is a session range thatactually occurred, never an interpolation.
- **Dashboard** — distance left to (or past) typical in both price points andpercent, how many of the last N sessions ran wider than typical, and optional detail rows (range so far, typical range, percentile standing,widest/narrowest, envelope and ladder values). Compact by default; everycryptic cell explains itself on hover; the whole panel can be switched off.
###How it works###
- **Typical range is user-selectable**, and the chart always names the activestatistic:
- **ADR** — the average of the last N completed session ranges (high − low).
- **ATR RMA** — the average true range, so overnight gaps count. Seeded withthe first true range rather than an initial SMA, which is why it is labelled "ATR RMA" and will not match `ta.atr()` to the last digit. Under ATR the numerator is the live session's true range too, so the percentageis never a ratio of two different measures.
- **Median** — the middle completed session range, which is also theladder's p50 rung.
- The three are identical on a symbol that never gaps and diverge as gaps grow — on heavily gapping symbols ATR can run near 2.5× ADR. That is why the choice exists and why the active one is named on the chart.
- **Completed sessions only.** The live day never feeds its own denominator —a partial day would drag the typical range down as the day progressed and bias the percentage upward with no symptom. Statistics update when a session completes; the live day contributes only its running range.
- **One session rule for everything.** Regular hours or regular + extended:history and the live day follow the same rule, and if the filter cannot change anything on your chart (no extended-hours bars loaded), the dashboard says so instead of staying silent.
- **The sample is what your chart holds.** n is capped by the sessions actually loaded — roughly 64 completed regular-hours sessions on a 5-minute chart from 5,000 bars on a Basic plan, more on higher plans and higher timeframes. The dashboard shows the n actually in use, plus a spread figure ((p90 − p25) ÷ p50) that says whether recent sessions were similar in size
or mixed.
- Eleven plotted values sit in the Data Window (percentage, ranges, envelope percentiles, sample size and more), so every number on the panel can be read, checked and exported.
###How to use it###
1. Add it to a liquid intraday chart. The defaults are the intended reading: compact dashboard, ADR(20), regular hours.
2. Read the headline first. ROOM means the day is still small next to its recent finished sessions; OVER TYPICAL means it has already run further than a typical one.
3. Use the envelope as context for the day's remaining room under the stated conditions — the tooltip on every input spells those conditions out.
4. Turn on the ladder to see today against the whole recent distribution instead of one average: price between p50 and p75 means today has already matched a mid-sized finished day.
5. Hover the bottom row of the dashboard whenever a figure is unclear — the statistic, the sample and any active caveat (gap counted, filter inert, no completed session yet) are explained there.
###What it deliberately does not do###
**Realized range from OHLCV — not an implied or expected move.** Every number is measured from this chart's own price history. Nothing comes from options pricing, and the typical range describes completed sessions — a description of what happened, not a statement about what happens next.
- No alerts, no signals, no entries or exits.
- Counts stay counts — "Sessions over typical: 4 of last 20" describes this chart's history, and the indicator never converts a count into odds.
- The percentage is never capped at 100%, because a day past its typical range is the most informative reading the tool produces.
###Why it is original###
Range tools usually hand you one number (an ADR level pair) or one overlay (an ATR band). Range Budget treats the session range as a budget and reports its consumption: one percentage against a user-chosen, chart-named statistic, computed from completed sessions only, with its sample size, its spread and every degeneracy disclosed on the panel itself. The three statistics are not interchangeable and the tool is built around that fact rather than hiding it: the active one is named on the chart, the ATR path measures true range on both sides of the ratio, and the ladder shows the whole recent distribution so one average never has to stand in for it.
Open source under the Mozilla Public License 2.0. All calculations are native
Pine v6 — no security() calls, no external data.
Indicator

