Rolling Quantile Bands
Standard deviation bands assume the recent price distribution is roughly symmetric around its mean - equally likely to stretch as far above as below. Real markets frequently are not: a market grinding higher with occasional sharp pullbacks has closes that pile up on the low side of its own recent range far more than a Gaussian assumption would suggest, and a symmetric band drawn from mean plus or minus a multiple of sigma misplaces both the upper and lower edge as a result. This indicator sidesteps that assumption entirely. Every bar, it sorts the closing prices in the trailing window and reads off the empirical percentile directly - no distributional shape is assumed anywhere in the calculation. The result is an envelope that reflects where price has actually spent its time recently, not where a bell curve says it should have. A median line is included alongside the two band edges so a skewed relationship between the median and either edge is visible at a glance. Because the window for every historical bar is built only from bars at or before it, a percentile band never shifts once its bar has closed - the whole envelope simply extends by one point as each new bar forms. Notes and limitations - The window is sorted fresh every bar; a very large InpPeriod on a long chart history will noticeably slow the first calculation pass, though normal ticking afterwards only recomputes new bars. - Percentiles are linearly interpolated between the two nearest sorted observations, the standard empirical-quantile convention - results will not exactly match every statistics package's default method on small windows. - This describes where price has recently traded, not where it will trade next; a close outside the band is a description, not a reversal signal on its own. - This does not size a position, place a stop, or account for spread and slippage.
Indicator · MT4 · v1.0 · Free
About Rolling Quantile Bands
Rolling Quantile Bands is an indicator for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 4 settings, such as Period, Upper percentile and Lower percentile. MQL source code included.
Files in the download: RollingQuantileBands.ex4, RollingQuantileBands.mq4, RollingQuantileBands.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Period | 100 | Closes in the rolling window |
| Upper percentile | 90.0 | Upper band percentile, 0-100 |
| Lower percentile | 10.0 | Lower band percentile, 0-100 |
| Alerts | true | Alert once per closed bar when price closes outside a band |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Indicators.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 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: Channels & Envelopes · Alerts · MT4 Indicator · MQL4 Source Code