Alım-satım robotlarını ücretsiz olarak nasıl indirebileceğinizi izleyin
Bizi Facebook üzerinde bulun!
Fan sayfamıza katılın
Kodu ilginç mi buldunuz?
Öyleyse bir link gönderin -
başkalarının da faydalanmasını sağlayın
Kodu beğendiniz mi? MetaTrader 5 terminalinde deneyin
Göstergeler

Range Compression Zones Breakout - MetaTrader 5 için gösterge

Domenico D'Errico
Yayınlayan:
Görüntülemeler:
167
Derecelendirme:
(1)
Yayınlandı:
MQL5 Freelance Bu koda dayalı bir robota veya göstergeye mi ihtiyacınız var? Freelance üzerinden sipariş edin Freelance'e git

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. 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:

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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

  1. 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.
  2. Pick the reference timeframe and lookback. The reference series must have history available; until it is loaded, the indicator waits and recalculates automatically.
  3. Watch the overlay: the ratio row shows when the last closed bar is compressed, and the zone row shows when a zone is armed.
  4. 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.
  5. For a confirmed signal, review the stop at the zone boundary and the target at your reward-to-risk multiple.
  6. 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.

Tick-Based Spread Distribution Profiler reads historical Bid/Ask ticks via CopyTicksRange Tick-Based Spread Distribution Profiler reads historical Bid/Ask ticks via CopyTicksRange

Tick-Based Spread Distribution Profiler reads historical Bid/Ask ticks via CopyTicksRange() and plots 24h spread percentiles (P50, P90, P99) in a separate subwindow. Key Features: - True Tick Percentiles: Plots Median (P50 histogram), P90 (orange line), and P99 (red dotted line) in points for every server hour (00-23h). - Unbiased Reservoir Sampling: Samples multi-week history within InpMaxSamplesPerHour without biasing early days. - Closed-Bar Friction Ratio: Uses closed-bar iATR (shift=1) to show Spread_P50 / ATR (%) and spot low-friction hours. - Clean Subwindow HUD: Displays global/current-hour stats and best/worst hours, with zero log spam and full OnDeinit() cleanup. - Optional CSV Export: Exports 24h Min/P50/P90/P99/Max stats to MQL5\Files\SpreadProfile_<Symbol>.csv. Inputs: InpLookbackDays (14), InpMaxSamplesPerHour (50000), InpAtrTimeframe (M15), InpAtrPeriod (14), InpRefreshMinutes (60), InpShowSummaryHUD, InpExportCSV.

Execution and Slippage Forensics audits MetaTrader 5 account history Execution and Slippage Forensics audits MetaTrader 5 account history

Execution & Slippage Forensics audits MetaTrader 5 account history (Orders vs Deals) to quantify real execution quality in points and currency. Key Features: - Order-to-Deal Matching: Pairs each fill to its parent order (ORDER_PRICE_OPEN vs DEAL_PRICE), skipping synthetic 0.0 prices. - Clear Sign Convention: (+) favorable price improvement, (-) adverse slippage. - 4-Category Breakdown: ALL_MEASURED, ENTRIES, SL_EXITS, and OTHER_EXITS (Mean, Median, Adverse %, Positive %, Net Slippage). - 24-Hour Profile: Identifies Broker Server hours where rollover or illiquidity worsens fills. - Hidden Execution Drag: Totals adverse slippage + commissions + fees + swaps vs Gross Winning Profit (%). - CSV Export: Saves ExecutionForensics_Deals.csv and ExecutionForensics_Hourly.csv to MQL5\Files\. Inputs: InpLookbackDays (90, 0=all), InpSymbolFilter, InpMagicFilter (-1=all), InpExportCSV, InpShowChartComment, InpTopWorstDeals.

Close All Positions and Orders (Filtered) Close All Positions and Orders (Filtered)

Closes open positions and deletes pending orders in one run, with filters for symbol, magic number, side and profit or loss. Asks for confirmation and retries failed closes.

Candle Timer and Spread Candle Timer and Spread

Shows the time left until the current candle closes and the live spread in any chart corner. Keeps counting every second, even when no ticks arrive.