Liquidity Sweep Detector
The pattern this looks for is one bar doing two things: its wick reaches beyond the nearest confirmed swing high or swing low - the level where stop orders are assumed to be resting - and its close lands back on the near side of that level. Stops beyond the swing get run by the wick, then price rejects, all inside one candle. That rejection is the liquidity sweep. The swing levels themselves come from an inline five-bar fractal (two bars either side), and a swing only counts once both of its confirming bars have closed. Two things are handled carefully here that a naive version misses. First, the bar being tested for a sweep is never allowed to also confirm the very swing it is being tested against - a bar cannot validate itself. Second, because the fractal centred two bars behind the current one is only confirmed after this bar's own sweep test has run, that confirmation becomes visible starting the following bar - the swing memory this indicator sweeps against is always the most recently confirmed one, not necessarily the single most extreme swing on the chart, and a fresh fractal always replaces whatever was tracked before it. Because the swing reference itself needs those two confirming bars, and the sweep marker only appears once its own bar has closed, this is a marker of a completed event on the current closed bar - not a live warning that a sweep is in progress while the bar is still forming. Notes and limitations - Only the single most recently confirmed swing high and swing low are held in memory at any time - this is not a sweep-of-any-historical-level detector, only the nearest untested one on each side. - A wick that reaches beyond the swing but closes beyond it too (a clean break rather than a rejection) is not marked - that is a real break of structure, not a failure, and is intentionally left to other indicators in this catalogue. - The five-bar fractal confirmation is coded inline and is not user-adjustable in this version; there is no input to widen or narrow it. - Because the swing memory only updates from confirmed fractals, a strong run of consecutive new extremes can temporarily leave the sweep test comparing against a level that is already a few bars stale.
Indicator · MT4 · v1.0 · Free
About Liquidity Sweep Detector
Liquidity Sweep Detector is an indicator for MetaTrader 4. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 2 settings, such as Alerts and Marker offset pips. MQL source code included.
Files in the download: LiquiditySweeps.ex4, LiquiditySweeps.mq4, LiquiditySweeps.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Alerts | true | Alert on a new sweep (closed bar only) |
| Marker offset pips | 3 | Marker distance from the wick, in pips |
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: Buy/Sell Arrows · Alerts · MT4 Indicator · MQL4 Source Code