Percentile Rank Oscillator
- Indicators
- Version: 1.0
- Activations: 5
# Percentile Rank Oscillator - Thresholds that are frequencies
*Category: Oscillators | Difficulty: beginner | Window: separate window below the chart | Markets: Universal (Forex, indices, commodities, crypto, stocks) | Suggested timeframes: M15, M30, H1, H4, D1*
## Short description
> An oscillator based on the percentile rank of price within its own recent distribution. A value of 90 always and everywhere means price is higher than ninety per cent of observations.
## Full description
### Overview
Classic oscillators have a structural flaw rarely discussed: their distribution depends on the market. A value of 70 may be reached every day on one instrument and once a month on another, so the same threshold means completely different things and the default values that work on a currency pair are unusable on an index. This oscillator fixes it at the root: it does not measure how far price has risen, but which percentile of its own historical distribution it sits in. A value of 90 always and everywhere means the same thing, that price is higher than ninety per cent of recent observations. Thresholds thus become actual frequencies rather than arbitrary numbers: setting 85 literally means flagging fifteen per cent of bars.
### How the calculation works
1. The applied price is smoothed over InpSmooth bars, without which the rank would jump constantly on single bar noise.
2. For each bar the number of window observations below the current value is counted.
3. Exactly equal values count as half: this is the standard mid-rank definition, avoiding distortion on discrete data.
4. The count is divided by the window size and multiplied by one hundred, giving the percentile directly.
5. Counting avoids sorting the window, sharply reducing computational cost compared with a sorting approach.
6. A signal average over InpSignalPeriod bars accompanies the main line.
### How to use it
- Set the thresholds thinking in frequency terms: 85 and 15 together flag thirty per cent of bars.
- The same threshold value works unchanged on any instrument and timeframe, making it ideal for basket monitoring.
- A rank of 50 indicates price sits exactly at the centre of its recent distribution, not that it is neutral in a directional sense.
- In a strong trend the rank stays steadily high: this is correct information to read as strength, not as a contrarian signal.
- Widening the window makes the rank steadier but slower to recognise a change in the price regime.
### Who it is for and on which timeframes
It is the simplest of the category and suits beginners too: the percentile concept is intuitive and requires no formal statistical background. It is particularly useful for traders monitoring many instruments together, because the scale is identical everywhere and values are directly comparable. It works on all timeframes from M15 up. Anyone looking for an oscillator that anticipates moves will be disappointed: this describes where price is, not where it will go.
### Practical example of reading a signal
A trader monitors six instruments with the same oscillator and the same thresholds at 85 and 15. On a classic oscillator they would have to remember that on gold a value of 70 is common while on EURCHF it is rare, mentally recalibrating every reading. Here that is unnecessary: on all six instruments a rank of 88 means exactly the same thing, that price is in the top twelve per cent of its own recent distribution. On that day only two instruments exceed the threshold, and those are where attention goes. Comparability is immediate because the scale is no longer a convention but a measured frequency.
## Input parameters
| Parameter | Default | Description |
|---|---|---|
| `InpPeriod` | 100 | Window of the reference distribution. It defines what counts as recent: long windows give stable but slowly adapting ranks. |
| `InpSignalPeriod` | 9 | Period of the signal average overlaid on the main line. |
| `InpUpperLevel` | 85.0 | Upper threshold, expressed directly as a percentile. With 85 the top fifteen per cent of bars is flagged. |
| `InpLowerLevel` | 15.0 | Lower threshold. If the two thresholds are inverted by mistake, the indicator reorders them automatically. |
| `InpSmooth` | 3 | Price smoothing before comparison. It prevents the rank from jumping on single bar noise. |
| `InpAppliedPrice` | PRICE_CLOSE | Price whose rank is computed. |
## Advantages / strengths
- The thresholds carry an objective frequency meaning rather than a conventional one: the same setting works everywhere.
- Values directly comparable across instruments, making it ideal for basket monitoring.
- The counting computation avoids sorting the window and is therefore far faster than the naive approach.
- An immediate concept, usable with no learning curve.
## Limitations and warnings
- The rank says nothing about the size of the move: a tiny rise and a huge one can produce the same value.
- In an extended trend the rank saturates at extreme values and stays there, losing discriminating power.
- After a structural market change the reference distribution stays anchored to the old regime for the whole window.
- Like every oscillator it describes the present state, it does not anticipate future movement.
**No repaint:** values printed on a closed bar are never modified afterwards.
**Disclaimer.** This product is a technical analysis tool, not an automated trading system, and it offers no profit guarantee whatsoever. Financial markets carry the risk of total loss of the invested capital. Past performance is not indicative of future results. Every signal must be confirmed with your own analysis, a money management plan and prior testing on a demo account. The author is not responsible for trading decisions taken on the basis of this indicator.
## Suggested tags / keywords for MQL5
`oscillator`, `percentile`, `rank`, `normalization`, `overbought`, `oversold`, `no repaint`, `market scan`
