Auto Range Rectangle Boxer
Manually drawing a consolidation box is easy to do too eagerly - almost any sideways stretch of five or six bars "looks like" a range if you squint. This indicator applies two objective filters before it draws anything: the box's height must not exceed a multiple of ATR (so a genuinely tight range, not just a quiet multi-day drift, qualifies), and each edge must have been individually touched at least InpMinTouches times within tolerance - a level only ever hit once on each side is a trend leg, not a range. Once a box is confirmed, it is re-tested on every new closed bar rather than fixed at formation: the right edge keeps extending forward while price keeps respecting both boundaries, and the box only stops extending - turning from the active colour to the broken colour, with one alert - the first time a bar CLOSES outside it. A new box cannot begin until the current one has broken, so boxes never overlap on the same chart. Notes and limitations The touch count only looks at wick extremes within tolerance of the edge - it does not weight how cleanly price respected the level beyond that. Because the box is re-evaluated only on bar close, an intrabar spike through an edge that closes back inside will not break the box; this is a deliberate design choice (see the header comment) matching how a trader reading a closed chart would judge the range, not a tick-by-tick monitor. Height is judged against ATR, not a fixed pip value, so it adapts across symbols and volatility regimes automatically, but that also means the same nominal range can qualify or fail to qualify as volatility itself changes.
Indicator · MT5 · v1.0 · Free
About Auto Range Rectangle Boxer
Auto Range Rectangle Boxer is an indicator for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 8 settings, such as Window bars, Max range atr mult and Atr period. MQL source code included.
Files in the download: AutoRangeRectangleBoxer.ex5, AutoRangeRectangleBoxer.mq5, AutoRangeRectangleBoxer.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Window bars | 15 | Minimum bars required to qualify as a range |
| Max range atr mult | 1.5 | Box height must not exceed this multiple of ATR |
| Atr period | 20 | ATR period used for the height test |
| Min touches | 2 | Minimum separate touches required on EACH edge |
| Touch tolerance pts | 30 | Points of slack counted as "touching" an edge |
| Active color | clrDodgerBlue | Colour while the box is still holding |
| Broken color | clrGray | Colour once price has broken out |
| Alerts | true | Alert once when a box breaks out |
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: ATR · Alerts · MT5 Indicator · MQL5 Source Code