Loading…

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 · MT5 · v1.0 · Free

About Rolling Quantile Bands

Rolling Quantile Bands is an indicator for MetaTrader 5. 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.ex5, RollingQuantileBands.mq5, RollingQuantileBands.txt.

Settings

SettingDefaultWhat it does
Period100Closes in the rolling window
Upper percentile90.0Upper band percentile, 0-100
Lower percentile10.0Lower band percentile, 0-100
AlertstrueAlert once per closed bar when price closes outside a band

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: Channels & Envelopes · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria