OBV Percentile Bands
On Balance Volume is a running total: each bar adds its tick volume if price closed higher than the previous bar, subtracts it if price closed lower, and leaves the total unchanged on an unchanged close. It is one of the oldest volume-based tools there is, and it is usually read against some kind of envelope or channel to judge whether the current reading is unusually high or low. The common approach - a channel built from the highest and lowest OBV value over a fixed lookback - is dominated by a single outlier bar. One unusually heavy print can hold the channel's edge in place for the entire lookback window, even while every other bar sits well inside it. A percentile band answers a different, steadier question: where does the current OBV value sit relative to the distribution of its own recent values, ignoring how extreme the single most extreme print was. OBV pushing through its own 80th percentile band means the current reading is genuinely unusual relative to the recent spread, not just relative to one outlier. The bands are computed by sorting the last InpLookback OBV readings and linearly interpolating the requested percentile rank from that sorted list - the standard empirical-CDF interpolation method. Notes and limitations - Uses broker tick volume, the standard native-MQL4 substitute for real traded volume on FX/CFDs. - OBV is cumulative from the first loaded bar, so its absolute level depends on how much chart history is loaded. This does not affect the percentile bands, which only compare recent OBV values against each other, but it does mean the raw OBV number itself is not comparable across symbols, brokers, or chart history lengths. - Needs InpLookback + 1 bars of history before the bands start plotting; the raw OBV line starts from the second available bar. - The percentile calculation sorts a window of InpLookback values on every newly formed bar; a very large InpLookback on a very long chart history will take proportionally longer to fully recompute the first time the indicator loads.
Indicator · MT5 · v1.0 · Free
About OBV Percentile Bands
OBV Percentile Bands is an indicator for MetaTrader 5. It has 3 settings, such as Lookback, Upper percentile and Lower percentile. MQL source code included.
Files in the download: ObvPercentileBands.ex5, ObvPercentileBands.mq5, ObvPercentileBands.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Lookback | 100 | Bars in the rolling percentile window |
| Upper percentile | 80.0 | Upper band percentile (0-100) |
| Lower percentile | 20.0 | Lower band percentile (0-100) |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the indicator from the Navigator onto a chart and adjust the settings.
Tags: Volume · Channels & Envelopes · MT5 Indicator · MQL5 Source Code