Riptide Sweep Reclaimer
- Experts
-
Syarief Azman Bin Rosli
Hello and welcome to my official MQL5 profile!
I am Syarief Azman Bin Rosli, an algorithmic trading systems developer and quantitative software engineer with over a decade of specialized experience creating robust automated trading solutions for MetaTrader 5 and MetaTrader 4. - Version: 1.1
- Activations: 5
Riptide Sweep Reclaimer is a MetaTrader 5 Expert Advisor that trades liquidity sweeps of a quiet-session range: it measures the high and low of a window you choose (default 00:00-08:00 server time), waits for the next session to push through one side and fades the move once a candle closes back inside, targeting the midpoint and the opposite side. One position at a time on the chart symbol; no grid, martingale or averaging.
Quick Start
- Attach the EA to one chart of the symbol (any timeframe; the logic runs on Working Timeframe, default M15) and enable Algo Trading.
- Set Range Start and Range End to the quiet session in broker server time (the Market Watch clock) and the hunt window after it with Hunt Window Start and Hunt Window End.
- Choose Position Sizing (default: 1% of balance per trade).
- The cockpit shows RANGE BUILDING during the range, then AWAITING HUNT or HUNTING.
- Quick check: a visual Strategy Tester run on EURUSD over a few weeks boxes each session and marks each confirmed sweep.
How It Trades
Range: high and low of the Working Timeframe bars opening between Range Start and Range End (may cross midnight). ATR is the average true range of the ATR Period bars ending at the last range bar. The session is a NO-TRADE DAY when the height is below Minimum Range Height or above Maximum Range Height (in ATR), or when under half of the expected bars exist (DATA GAP, e.g. holidays).
Sweep: during the hunt window each side is checked on closed bars.
- The side becomes PIERCED when a bar trades at least Minimum Sweep Depth x ATR beyond it.
- It is void as BREAKOUT if price goes more than Maximum Sweep Depth x ATR beyond, or NO RECLAIM if no confirmation comes within Reclaim Within bars (the piercing bar is bar 1).
- Entry Confirmation: Close back inside the range (a bar closes back inside); Close inside with a strong body (displacement) (plus a body of at least half an ATR in the trade direction); Close beyond the sweep candle (structure shift) (a later bar closes beyond the far end of the candle that made the extreme).
Entry: a market order at the open of the next bar. A sweep of the high gives a short, a sweep of the low a long. Each side trades at most once per session.
- Stop loss: sweep extreme plus Stop Buffer Beyond Sweep x ATR (plus spread for shorts), widened to the broker stop level if needed.
- Take-Profit Model: Range midpoint; Opposite side of the range; Partial at midpoint, rest at opposite side (default: at the midpoint Partial Close at Midpoint percent is closed and the stop moves to breakeven); Fixed reward-to-risk multiple (Fixed Reward-to-Risk times the stop distance).
- A signal is skipped if the reward to the final target is below Minimum Reward-to-Risk to Enter, if price is already past the midpoint in midpoint models, or if the spread exceeds Max Spread percent of the stop distance.
Management: Breakeven Trigger moves the stop to entry plus Breakeven Buffer at that many R of profit (0 = only after the midpoint partial). At Session Exit Time all positions of this EA on the symbol are closed. Daily Loss Limit: when this EA's closed plus floating result today reaches that percent of the day's starting balance, its positions are closed and entries pause until the next server day.
Position Sizing: Fixed lot uses Fixed Lot. Risk % of balance: lots = balance x Risk Percent per Trade / 100 / loss per lot at the stop. Fixed money risk per trade: lots = Risk Money per Trade / loss per lot. The result is rounded down to the volume step, capped by Maximum Lot and reduced when free margin is short. Below the broker minimum the minimum lot is used, so on very small accounts the real risk can exceed the setting.
Recommended: EURUSD, GBPUSD and other European pairs with the default Asian range, London hunt and M15. Gold and JPY pairs behave differently at the London open; test them first with Close beyond the sweep candle (structure shift) and Reclaim Within 5. Worth optimizing: range and hunt times, both sweep depths, Stop Buffer Beyond Sweep and Take-Profit Model.
Cockpit Buttons
- [-] / [+]: collapse the cockpit into a small pill (status, hunt countdown or live R of the open trade) or expand it again.
- <>: move the cockpit to the next chart corner.
- MOVE TO BE: move the stop of every open position of this EA to entry plus Breakeven Buffer. If price is too close to entry for the broker stop level, the log says so and nothing changes.
- CLOSE ALL: close every position of this EA on the symbol. The first click shows CONFIRM CLOSE ?, a second click within 4 seconds executes.
- ENTRIES ON / OFF: pause or resume new entries. Open positions are still managed.
- SIDE BOTH / LONG / SHORT: which sweeps may be traded.
- RANGES ON / OFF: show or hide the chart overlays.
Button states survive timeframe and symbol changes; re-attaching or editing inputs restores the input values.
Cockpit Readouts
- Status badge (also the LED and left accent color): ALGO TRADING OFF (trading disabled), DAILY LIMIT HIT, IN TRADE, ENTRIES OFF, RANGE BUILDING, NO-TRADE DAY, AWAITING HUNT (range locked, hunt not open yet), HUNTING (window open, a side can still trade; the LED blinks), SESSION DONE.
- Mode line: timeframe, take-profit model (MID, OPP, MID>OPP or the R multiple) and sizing.
- SESSION RANGE: window and state (BUILDING, LOCKED, TOO NARROW, TOO WIDE, DATA GAP); HIGH, MID and LOW; HEIGHT in points and ATR, plus ATR in points; TIDE, where Bid sits between range low (L) and high (H) in percent, or ABOVE / BELOW with the distance in ATR; HUNT with the window, OPENS IN, time LEFT or CLOSED, and EXIT time.
- SWEEP RADAR: rows for HIGH SIDE and LOW SIDE with the level and a status: STANDBY, WAITING, PIERCED (depth in ATR and bars used, e.g. 1/3), SIGNAL, TRADED (depth and signal bar time), SKIPPED with a reason, BREAKOUT, NO RECLAIM, NO SWEEP, OFF (side disabled) or - (no-trade day). The corner shows the confirmation (RECLAIM, DISPLACEMENT or SHIFT) and Reclaim Within.
- Skip reasons: ENTRIES OFF, DAILY LIMIT, MAX TRADES, POSITION OPEN, SYMBOL BUSY (netting: another position on the symbol), ALGO OFF, TRADE DISABLED, MARKET CLOSED (outside the trading session), PAST MIDPOINT, LOW RR (with the value), STOPS, SPREAD, NO MARGIN, VOLUME LIMIT, NO DATA, SEND FAILED (with the server code), LATE (signal came while the EA was off).
- POSITION: direction, volume, entry and floating profit; SL, TP and midpoint (MID DONE after the partial); an R meter from -1R to +3R, with BE once the stop is at breakeven; FLAT without a position. The corner shows the MAGIC number.
- SESSION & DAY: TRADES this session against Max Trades per Session; DAY P/L, REALIZED and FLOAT of this EA today; LOSS LIMIT meter of the loss used against Daily Loss Limit.
- ACTION DECK footer: the last log message.
Chart Overlays
Each session is a shaded box labelled RANGE (height in points and ATR, plus NO TRADE when skipped) with dotted high and low lines and a dashed midpoint across the hunt window. A coral down arrow marks a confirmed high-side sweep, an emerald up arrow a low-side sweep; hover for depth and signal time. On charts above H1 only the current session is labelled; hover a box for its details.
Alerts
Terminal Pop-Up Alerts and Push Notifications to Mobile (needs a MetaQuotes ID in Tools > Options > Notifications) report: trade opened, signal skipped (except ENTRIES OFF and LATE), midpoint partial, session exit, daily loss limit. None in the Strategy Tester.
Side Effects
Chart objects prefixed RSR_ (removed with the EA) and a 1-second timer on live charts; no files, global variables, DLLs or web requests. Closing deals carry the comments Riptide mid partial, Riptide session exit, Riptide daily limit or Riptide manual close.
Input Parameters
Session Range
- Range Start (00:00) and Range End (08:00): server time hh:mi.
- Working Timeframe (M15): the range must hold at least 4 bars.
- ATR Period (24): bars, 2-500.
- Minimum Range Height (2.5) and Maximum Range Height (12.0): in ATR.
Sweep Detection
- Hunt Window Start (08:00) and Hunt Window End (12:00): must start at or after Range End and end before the next Range Start.
- Minimum Sweep Depth (0.10) and Maximum Sweep Depth (2.50): in ATR.
- Reclaim Within (3): bars, 1-50.
- Entry Confirmation (Close back inside the range).
- Allowed Directions (Long and short): also Long only (low-side sweeps) and Short only (high-side sweeps). Starting value of the SIDE button.
Exits
- Take-Profit Model (Partial at midpoint, rest at opposite side).
- Partial Close at Midpoint (50): percent of volume, 0-100.
- Fixed Reward-to-Risk (2.0) and Minimum Reward-to-Risk to Enter (1.0): in R.
- Stop Buffer Beyond Sweep (0.25): in ATR.
- Breakeven Trigger (0 = off): in R. Breakeven Buffer (10): points.
- Session Exit Time (21:00): empty = off; must fall between Hunt Window End and the next Range Start.
Money Management
- Position Sizing (Risk % of balance).
- Fixed Lot (0.10), Risk Percent per Trade (1.0) and Risk Money per Trade (100, account currency).
- Maximum Lot (5.0; 0 = broker maximum).
- Max Trades per Session (2).
- Daily Loss Limit (3.0 percent of balance; 0 = off).
Execution
- Magic Number (20261012): the EA manages only its own positions on the chart symbol.
- Trade Comment (Riptide) and Max Slippage (20 points).
- Max Spread (20 percent of the stop distance; 0 = off).
Alerts and Cockpit
- Terminal Pop-Up Alerts (true) and Push Notifications to Mobile (false).
- Cockpit Dock Position (Top left; also Top right, Bottom right, Bottom left), Horizontal Margin (16) and Vertical Margin (28): pixels.
- Draw Ranges & Sweep Markers (true): starting value of RANGES.
- Past Sessions Drawn on Chart (5): 0-60.
Invalid times or windows stop the EA with a message in the Experts log; other values outside their range are clamped.
Typical Setups
- London fade (defaults): EURUSD or GBPUSD, range 00:00-08:00, hunt 08:00-12:00, Partial at midpoint, rest at opposite side, 1% risk.
- New York sweep of the London range: range 08:00-14:00, hunt 14:00-18:00, Session Exit Time 22:00.
- Conservative: Close beyond the sweep candle (structure shift), Reclaim Within 5, Range midpoint, Max Trades per Session 1.
- Prop-firm limits: Risk Percent per Trade 0.5, Daily Loss Limit 2, Session Exit Time 20:00.
Notes
- Hedging and netting accounts (on netting no entry while another position is open on the symbol). Every request is checked for stop and freeze levels, volume limits, margin and OrderCheck. Closes and stop moves are postponed and retried while price is inside the freeze level of the position's SL/TP or the market is closed.
- All times are server time; if your broker is not on GMT+2/+3, shift the windows by the difference.
Risk Disclaimer
Trading involves substantial risk of loss. Past or backtested results do not guarantee future results. Test on a demo account first and only risk money you can afford to lose.
