Sweep Reversal Base Rate Study
Liquidity-sweep-then-reversal is a popular setup description that is usually shown after the fact on a handful of cherry-picked examples, never as a base rate across an instrument's history. This script builds that base rate directly: it scans for bars whose high or low pushes beyond the prior N-bar swing extreme by at least a minimum penetration, then checks whether price retraces back beyond that same level by a confirming margin within a fixed lookahead, separately for sweeps of highs and sweeps of lows. The reversal threshold is measured from the swept LEVEL, not from the wick's own tip. Anchoring on the tip would reward a sweep that barely pierced the level with an easy "reversal" the instant price merely stalled, while penalising a much deeper sweep that genuinely reversed by the same absolute distance - measuring from the level being defended keeps the threshold comparable across sweeps of very different depths. Sweep detection is non-overlapping: once a sweep is found, the scan resumes after its tested lookahead span rather than re-detecting the same general wick as a fresh sweep against a barely-shifted swing extreme on the very next bar, which would otherwise inflate the sweep count on a single sustained push. Notes and limitations - This is a descriptive study, not a trading signal. A reversal percentage a few points either side of even on a small sample is not evidence of an edge; check the sweep count for the up and down buckets separately before acting on the table. - A bar whose range is wide enough to sweep both the prior high and the prior low in the same bar is skipped as ambiguous rather than counted for either side. - "Reversed" only checks whether the level was given back by the confirming margin at some point in the lookahead - it says nothing about how far price continued afterward, or whether a trade entered at the confirmation point would itself have been profitable once spread and slippage are accounted for. - The prior swing extreme is a plain rolling high/low over InpSwingLookbackBars, not a filtered or fractal-confirmed swing point - a longer lookback finds fewer, more significant levels.
Script · MT5 · v1.0 · Free
About Sweep Reversal Base Rate Study
Sweep Reversal Base Rate Study is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Symbol, Timeframe and Max bars. MQL source code included.
Files in the download: SweepReversalBaseRates.ex5, SweepReversalBaseRates.mq5, SweepReversalBaseRates.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Symbol | Symbol to study, blank = this chart's symbol | |
| Timeframe | PERIOD_H1 | Timeframe to study |
| Max bars | 5000 | Most recent bars to include |
| Swing lookback bars | 20 | Bars searched for the prior swing high/low |
| Sweep pips | 5.0 | Minimum penetration beyond that extreme to count as a sweep |
| Reversal pips | 10.0 | Minimum retracement back beyond the level to confirm a reversal |
| Lookahead bars | 20 | Bars checked (including the sweep bar itself) for a reversal |
| Save csv | true | Write every sweep event to a CSV file |
| Delimiter | DelimiterComma | CSV column separator |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT5 Script · MQL5 Source Code