Compression Zone Boxes
A single inside bar is common and mostly noise. A multi-bar chain of narrowing range is a genuine compression - a squeeze that eventually has to resolve - and that is what this indicator looks for, not individual bar patterns. Each bar is tested two ways: whether its range is narrow relative to ATR, and whether it sits fully inside the range built by the chain so far. Depending on the input, a bar joins the chain if it satisfies either test or, more strictly, both at once. A qualifying chain is boxed the moment it reaches the minimum length, with the box growing to cover the chain's full high/low range as more bars join. The box only appears once the minimum length is reached - a two-bar false start never gets drawn at all. The chain ends the moment a bar fails both tests. If that bar closes beyond the box, a breakout arrow is placed on it (up or down to match direction) and the box's colour freezes to the resolved colour for that direction, leaving a permanent visual record of which way the squeeze broke. If the breaking bar's close lands back inside the box's own range without extending it, the box simply freezes in its neutral colour with no arrow - a compression that ended without a directional resolution on the bar that broke the pattern. Notes and limitations - The ATR-based narrow-range test needs InpAtrPeriod bars of history before it produces a usable value; chains cannot be detected right at the start of a short-history chart. - "Breakout" here means a confirmed bar close beyond the box, not a wick poke - a large wick that closes back inside the compression range does not resolve the chain. - Recomputes the whole loaded history on every tick; compression chains are short-lived by nature so this has no meaningful running state to preserve across ticks, unlike a long-lived registry-style indicator. - Only one arrow is placed per resolved chain, on the exact bar that broke it - it is not a repeating breakout signal.
Indicator · MT4 · v1.0 · Free
About Compression Zone Boxes
Compression Zone Boxes is an indicator for MetaTrader 4 based on ATR. It draws buy and sell arrows on the chart. It has 7 settings, such as Min chain bars, Atr period and Nr multiplier. MQL source code included.
Files in the download: CompressionZoneBoxes.ex4, CompressionZoneBoxes.mq4, CompressionZoneBoxes.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Min chain bars | 3 | Minimum consecutive compressed bars before a box is drawn |
| Atr period | 14 | ATR period used for the narrow-range test |
| Nr multiplier | 0.6 | A bar counts as narrow when its range is below this times ATR |
| Require inside | false | Require strict inside-bar containment as well as narrow range |
| Box color | clrDarkSlateGray | Compression box colour while still active |
| Resolved up color | clrForestGreen | Box colour after an upward breakout |
| Resolved dn color | clrCrimson | Box colour after a downward breakout |
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 · ATR · Candlestick Patterns · Buy/Sell Arrows · MT4 Indicator · MQL4 Source Code