Loading…

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

SettingDefaultWhat it does
Window bars15Minimum bars required to qualify as a range
Max range atr mult1.5Box height must not exceed this multiple of ATR
Atr period20ATR period used for the height test
Min touches2Minimum separate touches required on EACH edge
Touch tolerance pts30Points of slack counted as "touching" an edge
Active colorclrDodgerBlueColour while the box is still holding
Broken colorclrGrayColour once price has broken out
AlertstrueAlert once when a box breaks out

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: ATR · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria