Node reference
Percentile Rank
Where the source sits among its previous N values, 0–100 — a regime score comparable across coins and years.
Rev. 2026.06
- period
- — Lookback length, in bars
- default 250
- range 1–5000
What it does
Ranks the current source value against its previous N values (the current bar is not in the window): 0 = below every one, 100 = above every one, 50 = middle. Ties count half, so a perfectly flat series reads 50.
What happens
Each candle it compares the new source value to the stored window, emits the rank, then slides the window forward. It has no value until N prior values exist (warmup = N bars). A bar whose source is not a finite number produces no output and leaves the window untouched. The period can be wired from another node for a dynamic lookback.
When to use
Turning a raw series into a relative regime read. The main recipe is a calm/wild volatility score on 1h bars: ROC(1) → Stdev(168) (7 days) → Percentile Rank(2000) (~3 months), then only allow trend or momentum entries while the score is below about 30. Rank it rather than thresholding raw volatility: a fixed volatility level means something different on every coin and in every year.
Gotchas
- It is a filter, not a signal — gate another entry with it; it will not tell you direction.
- It measures the past, so it lags regime changes.
- Evidence so far covers trend/momentum only; don't assume it helps mean-reversion.
- A threshold right at the boundary flickers on and off — add hysteresis (enter below 30, stay until above 40) or a Debounce.
- Long lookbacks need long warmups: 2000 1h bars is about 83 days before the first value.
- Ranks over different lengths are not interchangeable — rank(250) and rank(2000) answer different questions.
- Wired to a bucketed data node (Funding Rate, Derivatives Metrics) the period counts publications, not candles.
- Ties count half (Pine's ta.percentrank counts values ≤ the current one), so values differ from TradingView on flat stretches.