Sweep Zone Trap Placer
A liquidity sweep - price briefly pushing through a visible recent high or low, triggering the stop orders resting just beyond it, then reversing - is a recognisable pattern, but placing a manual stop order on every fresh swing extreme by hand is tedious and easy to forget after a level has already been swept once. This EA automates exactly that placement, nothing more. On every new bar it recomputes the highest high and lowest low over a configurable lookback (excluding the still-forming current bar), and maintains a buy-stop just above the recent high and a sell-stop just below the recent low, each with its own stop-loss and take-profit distance and a short expiration so an untouched trap does not sit stale for days. Traps are replaced, not endlessly modified, whenever the fresh swing level drifts far enough from the resting order's price to be worth the churn - a small configurable drift tolerance stops every single bar from cancelling and re-placing an order that is still sitting at essentially the same level. Every order this EA places carries its own magic number and is managed strictly by ticket, collected fresh from the order pool before any delete or replace action, never assumed to sit at a fixed position in the pool. RISK WARNING: breakout-stop entries on swept extremes can be whipsawed repeatedly in a ranging market, and each whipsaw pays the spread on both the stop order's fill and its stop-loss exit. Defaults are conservative but this can still lose money in choppy conditions - test on a demo account before funding it. Notes and limitations - This EA sends and cancels real orders on the attached symbol. Use conservative lot sizing and test on a demo account first. - A trap whose target level would land inside the broker's stop or freeze level is skipped for that bar rather than sent, and will be reconsidered on the next new bar. - Traps are only rebuilt on a new bar, not every tick - within one bar the resting orders are left alone. - The EA manages only its own magic number's pending orders on the attached symbol; it never touches a pending order it did not place. - Whipsaw risk in ranging markets is real and not eliminated by any filter here - this is a mechanical implementation of the pattern, not a market-regime detector.
Expert advisor · MT5 · v1.0 · Free
About Sweep Zone Trap Placer
Sweep Zone Trap Placer is an expert advisor (trading robot) for MetaTrader 5. It places pending buy/sell stop or limit orders. It has 10 settings, such as Magic, Lookback bars and Buffer pips. MQL source code included.
Files in the download: SweepZoneTrapPlacer.ex5, SweepZoneTrapPlacer.mq5, SweepZoneTrapPlacer.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Magic | 25300 | Magic number for every trap this EA places |
| Lookback bars | 20 | Bars used to find the swing high/low (excludes the current forming bar) |
| Buffer pips | 3.0 | Distance beyond the swing extreme where the stop order rests |
| Stop loss pips | 15.0 | Stop-loss distance from the trap's entry price |
| Take profit pips | 30.0 | Take-profit distance from the trap's entry price |
| Expiration minutes | 120 | Minutes before an untouched trap expires on its own |
| Lot size | 0.01 | Fixed lot size per trap |
| Replace drift pips | 2.0 | Rebuild a trap only once the fresh level drifts this far from the resting one |
| Max retries | 3 | Order send/delete attempts before giving up |
| Retry wait ms | 300 | Pause between retry attempts, milliseconds |
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 → Experts.
- 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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Pending Orders · MT5 Expert Advisor · MQL5 Source Code