Liquidity Sweep Levels
- Indicateurs
-
Muhammad Muqeem Korejo
Hi, I'm Muhammad Muqeem Korejo, an MQL4/MQL5 developer from Pakistan with 1.5 years of trading experience.
I build and fix trading tools for MetaTrader 4 and MetaTrader 5:
• Expert Advisors (EAs) built from your strategy rules
• Custom indicators, alerts and on-chart panels - Version: 1.0
Stop orders tend to collect above obvious highs and below obvious lows. Liquidity Sweep Levels draws these levels on the chart and shows when price runs through one of them and closes back on the other side. This pattern is commonly called a liquidity sweep or a stop hunt.
Levels
- Previous day high and low (PDH / PDL), from the daily candles of your broker. If a symbol has a short Sunday candle and no Saturday candle, Monday uses Friday's high and low. On symbols that trade every day, every day is used.
- Previous week high and low (PWH / PWL).
- Asia, London and New York session high and low. Each level is created when its session has ended.
- Equal highs and lows (EQH / EQL). Two confirmed swings at almost the same price (within a tolerance you can set), with no trading beyond them in between.
Each level type can be switched off, and each session can be switched off by leaving its time empty. A new day, week or session replaces the previous level of the same type. Equal levels expire after the number of days you choose, but never sooner than 50 candles.
Sweep rule
- A sweep of a high is a candle whose high goes above the level and whose close is back below it. A sweep of a low works the same way in the other direction.
- If the candle closes at or beyond the level, the level is marked as broken and no signal is given. This holds even when a minimum wick is set.
- The check is made only when the candle has closed. The arrow is placed on that candle and is not moved or removed later. A full recalculation (for example after the history is reloaded) starts at the same candle as before, so it gives the same signals.
- One candle gives at most one arrow per direction. When it sweeps several levels at once, the buffer reports the highest-ranked one: week, then day, then session, then equal.
Time handling
- Session times are entered in New York, London, UTC or broker time. Defaults in New York time: Asia 20:00–00:00, London 02:00–05:00, New York 07:00–10:00.
- Daylight saving is calculated from the US and EU calendar rules, so the sessions stay at the same local hours all year.
- The broker time zone is detected automatically, or you can enter its winter GMT offset and daylight saving rule.
- The panel shows the broker time zone that is in use, so you can check it.
Chart
- Active levels are solid lines. Swept levels stay dotted for the number of days you choose. Each line has a name and a tooltip.
- Active levels at almost the same price share one label, for example "PDL / NY L".
- With chart shift on, the level names sit to the right of the last candle. With chart shift off, they end at the last candle, so they always stay on the chart.
- A small panel shows the nearest active level above and below with the distance, the last sweep and the broker time zone.
- Each copy of the indicator creates and deletes only its own objects (names start with "LSL" and a number). Your own drawings and other copies are not touched.
Alerts (when a candle closes)
- Pop-up, sound, push notification and e-mail.
- At most one alert per candle.
- Alerts for equal highs and lows are optional, because they are more frequent.
For Expert Advisors
- Buffer 0: bullish sweep (low of the candle), EMPTY_VALUE when there is none
- Buffer 1: bearish sweep (high of the candle), EMPTY_VALUE when there is none
- Buffer 2: price of the swept low level (0 = none)
- Buffer 3: price of the swept high level (0 = none)
- Buffer 4: type of the swept low level
- Buffer 5: type of the swept high level
Type codes: 1 PDH, 2 PDL, 3 PWH, 4 PWL, 5 Asia H, 6 Asia L, 7 London H, 8 London L, 9 NY H, 10 NY L, 11 EQH, 12 EQL.
Read candle 1 (the last closed candle):
int h = iCustom(_Symbol, _Period, "Market\\Liquidity Sweep Levels");
double up[];
if(CopyBuffer(h, 0, 1, 1, up) == 1 && up[0] != EMPTY_VALUE)
{ /* a low was swept on the last closed candle */ } To pass inputs to iCustom, give them in the order of the inputs window. Each group heading ("Levels", "Sessions", "Broker time zone", and so on) also counts as one string parameter. Without the headings, iCustom returns error 4002.
A copy loaded by an EA through iCustom only fills the buffers. It draws nothing on the chart and gives no alerts, so it does not get in the way of a copy you attached yourself.
Inputs
- Levels: previous day, previous week, sessions, equal highs/lows (each on or off).
- Sessions: time zone of the session times, Asia / London / New York times as HH:MM-HH:MM (empty = that session off).
- Broker time zone: automatic, or manual winter GMT offset and daylight saving rule.
- Equal highs / lows: swing size, price tolerance (0 = automatic), how far back the first swing may be.
- Sweeps: minimum wick beyond the level, how many days an equal level stays active.
- Display: days of levels on the chart, swept levels on/off, names on/off, panel and its corner, colours, number of candles to calculate.
- Alerts: pop-up, sound, push, e-mail, and whether equal levels give alerts.
If a session time is not written as HH:MM-HH:MM (or left empty), or a number is out of range, the indicator does not start and writes a message in the Experts journal. Ranges: swing 1–20 candles, look back 10–5000 candles, days on the chart 1–60, expiry 1–365 days, broker offset −12 to +14 hours; tolerance and minimum wick cannot be negative. A number of candles below 500 is raised to 500.
Limits
- Session levels need a chart from M1 to H1. Daily levels need a chart below D1, and weekly levels a chart below W1. On W1 and MN the panel says so.
- On a new chart the indicator waits up to about a minute for the daily and weekly candles to load. If they arrive or change later, the levels are calculated again.
- In the Strategy Tester the broker time zone cannot be detected. The indicator then assumes GMT+2/+3 with US daylight saving. If your broker uses another time zone, set it manually.
- If the terminal starts without a connection, the broker time zone is checked again as soon as it connects, and the levels are recalculated if it changed.
- The indicator calculates the number of candles set in the inputs (5000 by default). When it is started again, for example after a restart of the terminal, the first candles of this range can show different signals, because the levels formed before them are not known.
- The indicator does not trade and does not predict price. It marks levels and reports what price did at them.
