Range Compression Zones Breakout

Range Compression Zones Breakout
Download ALL MT5 indicators (6102)
YouTube Video Thumbnail



Similar MetaTrader Tools

Range Compression Zones Breakout

Info

The Range Compression Zones Breakout is a Indicator for MetaTrader 5 that range compression zones breakout finds periods of narrowing range and draws each one as a zone on the chart. It follows the zone until a closed candle crosses one of its edges, then checks the cross against a higher-timeframe high/low filter and a rising-volume filter.

Usage

This tool is typically used for breakout trading when price moves beyond key support/resistance levels.

Platform

This Indicator works exclusively on MetaTrader 5 (both build 600+ and newer versions).

Setup

Place the downloaded file in MQL5/Indicators folder via File ? Open Data Folder in MetaTrader 5.


How to Install and Use Range Compression Zones Breakout

1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.

2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.

3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.

4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.

Frequently Asked Questions

Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."

Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).

Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.

What this tool does

Range Compression Zones Breakout finds periods of narrowing range and draws each one as a zone on the chart.

Typical Use Case

This Indicator excels in automated trading and technical analysis on MetaTrader 5.

Compatible Platform & Setup

This Indicator works on MetaTrader 5. Place the file in the MQL5/Indicators folder and restart the terminal.

Description & Settings

Related: Session Sweep Tracker: Asian Range Behavior at London Open - another powerful indicator for MetaTrader 5 traders.

Range Compression Zones Breakout finds periods of narrowing range and draws each one as a zone on the chart.

Also recommended: Range Expansion Clock: Identifying Peak Range Formation Hours - similar indicator with strong performance on MetaTrader 5.

It follows the zone until a closed candle crosses one of its edges, then checks the cross against a higher-timeframe high/low filter and a rising-volume filter.
A cross that passes both becomes a BUY or SELL signal with a reference entry, a stop at the opposite edge of the zone, and a target at your chosen reward-to-risk multiple.
A cross that fails is marked on the chart and the zone is closed.

A status overlay shows the live compression ratio, the active zone, the state of both filters, the signal counts and the latest signal.
The indicator supplies signals and analysis only. It does not open or manage any orders.

The idea is inspired by the range compression concept in Domenico D'Errico's Accumulation/Distribution study (Technical Analysis of Stocks & Commodities, August 2018). This is an independent implementation, not a literal port of the published study.



What market data or conditions the indicator analyses


The indicator reads OHLC candles, bar times, tick or real volume, and the high and low of a selected higher timeframe (H1, D1 or W1).
In ATR mode it also calculates a Wilder-smoothed ATR on the chart timeframe.
Its pipeline is:

Range measurement.
In High-Low mode the range is the highest high minus the lowest low over the last Length bars.
In ATR mode it is a Wilder-smoothed average true range over Length bars.

Compression ratio.
The current range is divided by the range measured Length bars earlier and multiplied by 100.
A bar is compressed when this ratio is strictly below the threshold (default 75%).
If the earlier range is zero or unavailable, no ratio is produced, so missing data can never look like compression.

Zone.
A compressed bar arms a zone from the highest high and lowest low of the last Length bars ending at that bar.
A further compressed bar re-arms the zone with the new window, so a run of compression is drawn as one box.
Only one zone is active at a time.

Closed-candle breakout.
A buy cross is a close above the zone high after a close at or below it.
A sell cross is a close below the zone low after a close at or above it.
Only completed candles are evaluated.

Filters.
The cross must pass the higher-timeframe high/low check and the rising-volume check, and the reference entry, stop and target must form a valid trade plan.

Length is a number of bars on the chart timeframe, not days or weeks.
The reference lookback is a number of bars on the reference timeframe.
A reference bar counts only once it was complete at the time the signal candle closed.



Data


How it is used


High, low, close

Range measurement, zone boundaries and the cross test.

Next bar's open

Reference entry price of a confirmed signal.

Tick or real volume

Two summed volume windows are compared by the volume filter.

H1, D1 or W1 high and low

The latest completed reference bar is compared with the bar Lookback bars earlier.

Bar times

Placing boxes, markers and lines, and deciding which reference bars were complete at the signal time.



How to interpret signals and visual elements


Confirmed buy and sell signals

A buy signal needs a closed candle that crosses above the zone high, a latest completed reference low that is higher than the reference low Lookback bars earlier, and recent volume that is rising.
A sell signal needs a close below the zone low, a latest completed reference high that is lower than the reference high Lookback bars earlier, and rising volume.
A buy arrow sits below the signal candle and a sell arrow above it.

The arrow is placed on the signal candle, not at the reference entry price.
The entry is the open of the next bar.
A cross always closes the zone, whether it passes the filters or not.
After a confirmed signal the zone is cleared and no new zone is armed on that bar.

The reference filter can be switched off.
In that case a cross is accepted when the volume check and the trade plan are valid.



Element

Interpretation


Active zone

Dashed box in the active zone colour (blue by default), stretched to the current bar.
Its edges are the highest high and lowest low of the arming window.

Finished zone box

Solid box from the start of the zone window to the signal candle.
Green for a confirmed buy, red for a confirmed sell, grey for a cross rejected by a filter.

Zone tag

For example
RC HL 54.2% (<75%)
: range mode, compression ratio at the arming bar, threshold, then the outcome (BUY, SELL or FILTERED).
The ratio is a measurement, not a quality score.

Buy / sell arrow

A confirmed signal on a closed candle.
Green up arrow below the candle for a buy, red down arrow above it for a sell.

Grey cross mark

A breakout that crossed the zone edge but was rejected by a filter or by an invalid trade plan.
It is shown so you can see what was filtered out.

Entry, SL, TP lines

Short horizontal lines starting at the bar after the signal:
dotted entry, solid stop, solid target, each with a price tag.

Reference lines

The latest completed reference high and low (solid) and the high and low Lookback bars earlier (dotted).
Lows are drawn in the buy colour and highs in the sell colour.
They show the current state, not the state at the time of an older signal.

Status overlay

Text rows in the chosen chart corner, described below.

Entry, stop and target

Entry:
the open of the bar after the signal candle.
Spread is not modelled.

Buy stop:
the bottom of the zone.
Sell stop:
the top of the zone.

Risk:
the distance between the entry and the stop.
If the entry is not on the correct side of the stop (for example after a gap), there is no valid trade plan and the cross is shown as filtered.

Target:
the entry plus (buy) or minus (sell) the risk multiplied by the Reward-to-Risk Ratio (default 2.0).

The stop is based on the zone boundary, not on the candle wick.
There is a single target.
The levels are a reference plan, not a broker position, and no trailing or break-even logic is applied.



Status overlay


Row

Meaning


Mode

Range mode, Length and threshold in use.

Ratio

Compression ratio of the last closed bar, flagged COMPRESSED or normal.

Zone

ARMED with the zone low and high, or none.

Ref

Whether the reference filter would currently accept a buy and a sell, as of now.
It describes the present state of the reference timeframe, not a past signal.

Volume

Whether the volume condition is met on the last closed bar.

Signals

Count of confirmed buys, confirmed sells and filtered crosses in the calculated history.

Last

Direction and time of the latest confirmed signal.



Alerts and buffers

Alerts:
popup, mobile push and sound, sent once per confirmed signal bar with the symbol, timeframe, direction, entry, stop and target.
Because a signal is confirmed on a closed candle, the alert appears when the next bar opens.
Signals that already exist when the indicator starts, or that reappear after a recalculation, do not alert.

Buffers:
RangeRatio (0), Compression (1), Range (2), BuySignal (3) and SellSignal (4).
The signal buffers hold the close of the signal bar.
A ratio and a compression flag are empty while history is too short or the earlier range is unusable.



Key settings and parameters


The table covers every input.
Colour defaults can be changed in the input dialog.



Setting (input name)

Default

Description


Range Compression

Range Length / Offset
(InpLength)

4

Range window and comparison offset, in bars of the chart timeframe.
Range 1-10000.

Compression Threshold (%)
(InpFactor)

75

A bar is compressed when the recent range is strictly below this percentage of the past range.
Lower values find only stronger compressions.
Range 0-1000.

Calculation Mode
(InpMode)

High-Low

High-Low range or ATR with Wilder smoothing, both using Length.



Volume Confirmation

Minimum Volume Ratio
(InpVolRatio)

1.0

Recent volume must be greater than the earlier volume multiplied by this value.

Volume Average Length
(InpVolAvgLength)

4

Number of bars summed in each of the two windows being compared.

Volume Average Delay
(InpVolDelay)

4

The recent window ends this many bars before the signal candle.
The earlier window is one averaging length further back.

Volume Source
(InpVolumeType)

Tick volume

Tick volume or real volume.



Higher-Timeframe Filter

Enable High/Low Filter
(InpUseReferenceFilter)

true

Turns the higher-timeframe filter on or off.

Reference Timeframe
(InpReferenceTf)

D1

H1, D1 or W1.

Lookback Bars on Reference Timeframe
(InpReferenceLookback)

12

The latest completed reference bar is compared with the bar this many bars earlier.
W1 with 12 compares with 12 weeks earlier; D1 with 12 compares with 12 days earlier.



Risk and Targets

Reward-to-Risk Ratio (1:R)
(InpRewardRisk)

2.0

The target is placed at this multiple of the distance between the entry and the stop.
There is one target; no separate TP levels.



Display

Max History Bars to Render
(InpDisplayBars)

1500

Zones, arrows and trade levels are drawn only for this many recent bars.
Older history is still calculated.

Fill Zone Boxes
(InpFillZones)

true

Fills the zone boxes. Turn it off for outline-only boxes.

Show Zone and Price Tags
(InpShowLabels)

true

Shows the zone tags and the price tags on trade levels and reference lines.

Show Entry / SL / TP Lines
(InpShowTradeLevels)

true

Draws the entry, stop and target lines for confirmed signals.
Does not change the signal buffers.

Trade Line Length (Bars)
(InpTradeBars)

12

Length of the trade-level lines in bars.

Show Filtered-Out Crosses
(InpShowRejected)

true

Draws a grey cross mark where a breakout was rejected.

Show Reference High/Low Lines
(InpShowReference)

true

Draws the latest and the lookback reference highs and lows.

Show Status Overlay
(InpShowOverlay)

true

Shows or hides the status overlay.
Calculations continue while hidden.

Overlay Corner
(InpOverlayCorner)

Top left

Chart corner for the status overlay.



Colours

Active Zone Color
(InpZoneColor)

DodgerBlue

Colour of the active zone and of the entry line.

Buy Signal and Target Color
(InpBullColor)

SpringGreen

Colour of buy signals, buy zones, target lines and reference lows.

Sell Signal and Stop Color
(InpBearColor)

Crimson

Colour of sell signals, sell zones, stop lines and reference highs.

Filtered Cross Color
(InpRejectedColor)

SlateGray

Colour of crosses rejected by a filter.



Alerts

Pop-Up Alert on Signal
(InpAlertPopup)

true

Shows a terminal popup when a confirmed signal appears.

Mobile Push Notification
(InpAlertPush)

false

Sends the signal to the MetaQuotes ID configured in the terminal.

Play Sound on Signal
(InpAlertSound)

false

Plays a sound when a confirmed signal appears.

Alert Sound File
(InpAlertSoundFile)

alert2.wav

WAV file in the terminal's Sounds folder.



Typical use cases and trading scenarios


Use case

Example scenario

Interpretation


Breakout after compression (buy)

A zone forms, a candle closes above its high, the reference low is higher than 12 reference bars earlier, and volume is rising.

A buy signal is confirmed on that candle.
Review the stop at the bottom of the zone and the resulting target before relying on it.

Breakdown (sell)

A candle closes below the zone low, the reference high is lower than 12 reference bars earlier, and volume is rising.

A sell signal is confirmed.
The stop is at the top of the zone.

Filtered breakout

A candle closes above the zone high but the reference low is not higher, or volume is not rising.

No signal.
A grey cross is drawn, the zone is closed and the box turns grey.



Choosing the reference timeframe

Trading M5 with D1 and a lookback of 12 versus W1 and a lookback of 12.

The first compares today's context with about 12 days earlier, the second with about 12 weeks earlier.
Compare the two on the same chart and data.



High-Low versus ATR mode

Switching the mode while keeping Length and the threshold unchanged.

The two modes measure range differently, so they find different compressions.
Judge them on the same symbol and period.



Threshold research

Lowering the threshold from 75% to 60%.

Fewer, stricter compressions.
It changes what qualifies, not how good a signal is.



Expert Advisor integration

An EA reads BuySignal and SellSignal through iCustom.

The EA can use the confirmed signals and apply its own execution, sizing and position rules.



Example workflow

Attach the indicator and choose the range mode, Length and threshold.
Make sure the chart has enough history: roughly two Length windows are needed before the first ratio appears.

Pick the reference timeframe and lookback.
The reference series must have history available; until it is loaded, the indicator waits and recalculates automatically.

Watch the overlay: the ratio row shows when the last closed bar is compressed, and the zone row shows when a zone is armed.

Wait for a closed candle to cross the zone.
Check whether the result is an arrow or a grey cross, and read the zone tag.

For a confirmed signal, review the stop at the zone boundary and the target at your reward-to-risk multiple.

When comparing settings, keep the symbol, timeframe and period fixed and change one input at a time.



Who is this indicator best suited for?


User profile

How it helps


Breakout and price-action traders

Shows periods of narrowing range as boxes and applies the same rules to every breakout of them.

Multi-timeframe analysts

Adds a higher-timeframe high/low comparison and shows the reference levels it uses.

Strategy developers

Supplies the ratio, compression flag, range and signal buffers for custom indicators and Expert Advisors.

Researchers

Makes it easy to compare thresholds, range modes, reference timeframes and volume settings on the same data.

Learners

Separates the steps of compression, zone, cross, filters and trade plan, and shows which step rejected a breakout.

The indicator is best suited to users who understand range, ATR, higher-timeframe context and risk multiples.
It supplies signals and reference levels.
Execution, position sizing and account risk are left to you.



Important limitations and usage notes

Closed-bar timing:
Zones and signals are evaluated on closed bars, and a confirmed signal does not change afterwards.
The active zone box and the status overlay update while the current bar forms.

Alert timing:
The alert appears when the bar after the signal candle opens.
Each signal bar alerts once, and signals that existed when the indicator started do not alert.

Simple reference filter:
The filter compares one reference bar with another Lookback bars earlier.
It is not a trend measure and does not check what happened in between.

Reference lines show now:
The reference lines and the Ref overlay row use the current state, so they do not show the levels that applied to older signals.

Reference data:
The selected reference timeframe must have history available.
Until it is loaded, the indicator waits and recalculates automatically.

Volume source:
Tick volume is the default and its meaning depends on the broker and symbol.
Select real volume if your symbol provides it.

Zones are not forecasts:
A compression zone does not predict the direction of the next move or the chance of success, and a tighter ratio is not a quality score.

No performance statistics:
The indicator does not report win rates, target hit rates or profitability.
Counts in the overlay are detections only.

No order management:
It does not place or modify orders and applies no trailing stop or break-even logic.

Settings change results:
Length, threshold, mode, volume settings and the reference timeframe all change which zones and signals appear.
More signals are not better signals.

Display range:
Only the last Max History Bars to Render bars get boxes, arrows and trade lines.
Older history is still calculated.

Independent implementation:
The indicator is inspired by the range compression concept in D'Errico's study and is not a literal port of it.

You may also like: Key Trading Levels Indicator: PDH/PDL, Weekly, Monthly, Midnight Open, Asian Range, and Sweeps - excellent alternative for indicator users on MetaTrader 5.

Source Code

#property copyright "RobotFX"
#property link "https://robotfx.org"
#property version "1.00"
#property description "This code is educational. Feel free to use, modify and upgrade as you wish. Visit ROBOTFX.ORG for professional trading tools"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots 5
#property indicator_label1 "RangeRatio"
#property indicator_type1 DRAW_NONE
#property indicator_label2 "Compression"

.......

Leave your opinion, ask a question, share some knowledge

⚠ Limitations & Risk Warning

  • This tool is provided for educational and testing purposes only.
  • Past performance does not guarantee future results.
  • Trading involves substantial risk of loss. Use on a demo account first.
  • Results may vary depending on market conditions, broker, and settings.
  • We recommend thorough backtesting and forward testing before using with real funds.
© ROBOTFX Free educational tools by RobotFX. Use entirely at your own risk; we are not liable for any financial losses incurred.