RobotFX curates the best open-source MetaTrader code to inspire your trading automation.
Equal highs and equal lows on Gold (XAUUSD) or any symbol are drawn as liquidity lines: two or more confirmed swings that end within a small distance, measured as a fraction of ATR, with no candle between them running the level first. Every new swing at the same price adds a touch to the line.
When a later candle trades beyond the line and closes back inside, the level is marked as swept, the buy side or sell side liquidity was taken and price returned. When the candle closes beyond the line, the level is marked as taken instead, so a real breakout is not confused with a sweep.
Swings are confirmed on closed bars, so the lines appear a few bars after the second swing and do not repaint. A sweep shows where stops were run, it does not say where price goes next. Test it on your symbols before you trade it.
Never miss news-driven moves – use the News OCO Expert Advisor to place pending orders safely around economic releases. Find out more.
Settings
- Swing length: bars on each side that confirm a swing. Default 3.
- Tolerance: two swings count as equal when they differ less than this many ATR. Default 0.10.
- ATR period: default 14.
- Maximum bars between the two swings: default 100.
- Bars to scan: history used on load. Default 1500.
- Show equal highs / equal lows, maximum active levels, maximum swept levels, keep taken levels, colours, line width and font size.
- Alerts: new equal high or low and sweep, by popup, push and sound.
- Object prefix: change it to run two copies on one chart.
What it needs
Any symbol, any timeframe, any broker. It only draws lines and labels, it never trades.
Make it yours
Try it on XAUUSD, EURUSD, GBPUSD, US30 and NAS100 on M5, M15 and H1. A tighter tolerance keeps only clean double tops and bottoms, a wider one finds more pools. Liquidity sweeps are the first step of many Smart Money Concepts setups: the sweep, then a change of character, then a return to an order block or a fair value gap. XP_AddSwing builds the levels and XP_CheckSweeps classifies sweep or taken, both ready to reuse as a filter in your own EA.
About this code
Open source. Use it as it is, adapt it, build your own version on top of it.
New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander
Questions, suggestions and your own backtests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01
More tools on my profile: https://www.mql5.com/en/users/09151993a
Provided as is, use at your own risk.
Related
- Fair Value Gap Zones Tracker
- Order Blocks Zones SMC
- Smart Money Concepts BOS CHoCH
Changelog
- v1.0 - 2026-11-02 - Initial release
Level up your trading with professional RobotFX expert advisors and indicators. Visit robotfx.org for proven MT4/MT5 tools.
79401