Opening Range Statistical Bands
An opening range breakout system needs a target or stop distance beyond the range, and the naive version of this tool multiplies the range by a fixed constant such as 1x or 2x because it looked right on one chart. This indicator measures the real number instead: over InpLookbackDays completed days it finds each day's opening range (a fixed window at a configurable start time and duration), then checks how far price extended past the opening range high on days that broke up, and separately how far it extended past the opening range low on days that broke down. The two are rarely symmetric, so they are tracked and averaged independently, and any single day's measured multiple is clamped to InpMaxExtensionMultiple before averaging so one freak news day cannot dominate the statistic. Today's opening range prints as two horizontal levels once its window completes. Two further bands are drawn using the measured average extension multiples: opening range high plus the average up-extension multiple times the range, and opening range low minus the average down-extension multiple times the range - both labelled with the multiple and the sample count (n) they were measured from, so a trader can see immediately how much history actually backs each band. Notes and limitations - If no days in the lookback window ever broke a given direction, the average multiple for that side defaults to 1.0x (one full opening range beyond the level) rather than an undefined value, and the label's sample count (n=0) makes this visible. - Statistics are rebuilt once per calendar day, not every tick, since they do not change intraday; this keeps the indicator responsive even with a large InpLookbackDays on a low timeframe. - Opening range and post-range scans read the CURRENT chart's own timeframe bars; running the same symbol on two different timeframes can give slightly different opening range boundaries if the range window does not align exactly with that timeframe's bar edges. - No trade or stop-loss logic - visual analysis only.
Indicator · MT4 · v1.0 · Free
About Opening Range Statistical Bands
Opening Range Statistical Bands is an indicator for MetaTrader 4. It has 9 settings, such as Or start hour, Or start minute and Or duration minutes. MQL source code included.
Files in the download: OpeningRangeStatBands.mq4, OpeningRangeStatBands.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Or start hour | 8 | Opening range start hour (broker time, 0-23) |
| Or start minute | 0 | Opening range start minute (0-59) |
| Or duration minutes | 30 | Opening range duration, in minutes |
| Lookback days | 20 | Completed days used to measure break-and-extend statistics |
| Max extension multiple | 5.0 | Clamp on any single day's measured extension multiple |
| Or color | clrGoldenrod | Opening range high/low colour |
| Upper band color | clrLimeGreen | Average up-extension band colour |
| Lower band color | clrCrimson | Average down-extension band colour |
| Show labels | true | Show text labels on the bands |
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: Breakout · MT4 Indicator · MQL4 Source Code