Stagger Stops Against Sweeps
Stops tend to end up on the same price for reasons that have nothing to do with risk management: a round number, a swing low everyone can see, three tickets opened from the same template on the same day. A liquidity sweep that reaches that one price takes out every ticket sitting on it together, in one tick, rather than testing each one on its own merits. This script scans the matched positions, groups them by symbol and direction, and finds every group of at least InpMinGroupSize tickets whose stop sits within InpToleranceSamePips of each other. The first ticket found in each group - the anchor - is left exactly where it is. Every other ticket in the group gets moved by a random distance between InpMinOffsetPips and InpMaxOffsetPips, in a random direction, so the cluster becomes a narrow band of separate prices instead of one shared line. Every candidate offset is checked against the broker's minimum stop distance before it is sent, and is never allowed to cross the position's own open price - staggering spreads a cluster apart, it does not turn a stop-loss into a guaranteed-profit close by accident. If the randomly chosen direction does not fit, the script tries the opposite direction before giving up on that one ticket and reporting it, rather than silently leaving a level unstaggered without saying so. Running the script again is safe. A cluster that has already been spread apart no longer matches the tolerance, so it is left alone; only newly formed clusters get touched. Notes and limitations - Only market positions are touched. Pending orders have no live stop for a sweep to hunt, so they are excluded from the scan entirely. - The anchor ticket in each group (the first one found) never moves. Which ticket becomes the anchor depends on order-pool position, not on any property of the ticket itself. - A ticket whose offset range does not fit between the open price and the broker's minimum stop distance is left unchanged and reported, never approximated to the nearest allowed price. - This changes where a stop sits by a few pips; it does not change the fact that the position is exposed to a genuine trend move through that whole band. It defends against a level being an exact, known target - nothing more. - The script runs once per invocation and does not watch for new clusters forming afterward.
Script · MT4 · v1.0 · Free
About Stagger Stops Against Sweeps
Stagger Stops Against Sweeps is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Current symbol only, Magic filter and Min group size. MQL source code included.
Files in the download: StaggerStops.mq4, StaggerStops.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Current symbol only | false | Restrict to this chart's symbol |
| Magic filter | -1 | Only this magic (-1 means every magic) |
| Min group size | 2 | Minimum tickets sharing a level before staggering |
| Tolerance same pips | 0.0 | Treat stops within this many pips as identical |
| Min offset pips | 1.0 | Smallest random offset applied, in pips |
| Max offset pips | 5.0 | Largest random offset applied, in pips |
| Also stagger targets | false | Also stagger identical take-profit clusters |
| Max retries | 5 | Attempts per ticket before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
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 → Scripts.
- 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 script onto a chart to run it once.
Tags: Risk & Lot Size · Alerts · MT4 Script · MQL4 Source Code