OPEN-SOURCE SCRIPT
Обновлено

Percentile Context [RC Tools]

225
RC Tools — Percentile Context
─────────────────────────────────────────────────────────────

█ OVERVIEW

Not "is RSI over 70" — "where does today's reading actually sit in its own history?" This tool takes a metric of your choice (realised volatility, RSI, volume, rate of change, or any custom source you plug in) and ranks it as a percentile against its own trailing distribution. It's the statistical primitive underneath most technical analysis, made explicit instead of buried in a fixed threshold.

█ WHAT IT DOES

Plots a 0–100 percentile-rank line for the selected metric, flags "extreme" zones (default: below the 10th percentile or above the 90th), and shows a stats table with the current value, current percentile, all-time min/max seen on the chart, and how many bars it's been since the metric last hit either extreme.

█ THE THEORY BEHIND IT

Fixed thresholds ("RSI > 70 = overbought") assume a metric's meaningful range never changes. It does — across assets, and across time on the same asset. A percentile rank fixes this by asking a relative question instead of an absolute one: given everything this metric has done over its own trailing window, how unusual is today's reading? This is the same idea underneath the Regime Classifier's volatility-state measure, generalised to any metric.

█ HOW IT IS CALCULATED

The selected metric is computed per bar:

• Realised Volatility: stdev(log(close/close[1]), N)
• RSI: standard Wilder RSI
• Volume: raw bar volume
• Rate of Change %: (close − close[N]) / close[N] × 100
• Custom Source: whatever series you plug into the source input (e.g. another indicator's plot)

The metric is then percentile-ranked against its own trailing window (default 750 bars ≈ 3 years on daily): what percentage of the last N readings were below today's value. Display values update ONLY on confirmed bar close — nothing here repaints.

█ SETTINGS & CONFIGURATION

• Metric (default Realised Volatility) — what gets ranked
• Custom Source — only used when Metric = Custom Source
• Realised Volatility / RSI / Rate of Change lookbacks (defaults 20 / 14 / 20)
• Percentile Ranking Window (default 750 bars) — longer = more stable, needs more history
• Low / High Extreme Thresholds (default 10 / 90)
• Paint Main Chart Background — off by default to avoid clashing with the Regime Classifier's background if you run both at once

█ HOW TO USE IT

Use it to calibrate how seriously to take a "normal" indicator reading. Example: RSI at 75 means something different on a stock that's rarely above 60 than on one that regularly touches 85 — the percentile rank makes that comparison explicit for the SAME asset over time. Also useful for volatility context ahead of position sizing: current realised vol at the 95th percentile is a different risk environment than the same absolute vol reading at the 40th percentile.

Works on any asset and timeframe with sufficient history for the percentile window.

█ LIMITATIONS

• Percentile rank describes the past relative to itself — it says nothing about direction or what happens next. A metric at its 99th percentile can stay there.
• Needs substantial history for a stable ranking. On short-history assets, treat the percentile as unreliable.
• "Extreme" is relative to the metric's OWN range. A percentile extreme on a low-volatility asset is not directly comparable in absolute terms to one on a high-volatility asset — that's the point of the tool, but it means percentiles aren't comparable across symbols.
• All-time min/max and "bars since" stats are only as long as the chart's available history, not a fixed universal record.
• This script does NOT repaint. Display values update on confirmed bar close only.

█ DISCLAIMER

For educational and informational purposes only. Nothing here is financial advice. Past behaviour of any metric does not indicate future results. Trade at your own risk.
Информация о релизе
Minor code cleaning adjustments.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.