Liquidity Zones MTF
- Göstergeler
- Sürüm: 1.5
- Etkinleştirmeler: 5
Liquidity Zones MTF keeps track of the nearest untouched swing high above price and the nearest untouched swing low below price, and shows what happens when price reaches them. The same logic runs a second time on a higher timeframe, and the higher-timeframe levels and events are drawn on your chart. Only closed candles are used: a value for a candle is written after that candle closes and is never changed afterwards.
HOW THE LEVELS ARE FOUND
- A swing high is a candle whose high is not exceeded by N candles on each side (Swing strength, default 5); a swing low is the mirror. When several candles share the same high, the latest of them is the swing.
- The nearest swing high above the last close is the BSL edge (buy-side liquidity); the nearest swing low below it is the SSL edge (sell-side liquidity). The indicator stores up to 25 levels on each side; a level that price has already passed is dropped.
- When a candle wick goes beyond a level and the candle closes back on the inner side, the level is treated as swept and removed from the list. The sweep is remembered as a candidate only if it is deep enough (Min sweep depth x ATR), the candle closed in the far part of its range (Min rejection) and the previous sweep on that side is at least Cooldown bars old.
- If, within the Confirm window after the sweep, a candle closes back beyond the swept level with a body larger than Displacement x ATR (ATR 14 of the candle before the sweep), the candidate is confirmed as a liquidity grab: "LG" is written on the sweep candle, below the low for a bullish LG, above the high for a bearish one.
- If a candle closes beyond the level, it is a break of structure: an arrow is drawn under that candle for a break above BSL and over that candle for a break below SSL. "BOS marks" can show only breaks that change direction (default), all breaks, or none.
- Levels within Equal-level tolerance x ATR of a swept or broken level are removed together with it.
HIGHER TIMEFRAME
The higher timeframe (HTF) is chosen automatically from the chart period - M1-M5: H1, M6-M30: H4, H1-H12: D1, D1: W1, W1: MN1, MN1: off - or set in the inputs; it must be above the chart period. The HTF engine uses the same rules on HTF candles. The HTF state shown on a chart candle is the state after the last HTF candle that had closed when the chart candle opened, so an HTF event appears on the first chart candle of the next HTF candle and does not move later. HTF history is loaded by the terminal on first use; the status line shows "waiting for history" until the HTF candles that cover the chart window are available, and the HTF layer is then drawn in one pass.
WHAT YOU SEE
- BSL edge and SSL edge lines of the chart timeframe (width 2) and of the higher timeframe (width 1), coloured from the chart background: orange tones above price, blue tones below, muted grey for BOS marks; the colours switch when you change the chart theme.
- Tags "BSL" / "SSL" and "BSL H4" / "SSL H4" (the HTF name) to the right of the last candle.
- "LG" marks on confirmed liquidity grabs; HTF marks read "LG H4".
- BOS arrows; HTF arrows are thicker. Every mark has a tooltip with its type and time.
- A status line in the top-right corner: instance ID, symbol, timeframe, the HTF in use and the first HTF date in the calculation.
BUFFERS FOR EXPERT ADVISORS
The indicator exposes eight buffers (iCustom / CopyBuffer), all with EMPTY_VALUE where there is no value:
0 BSL edge, 1 SSL edge, 2 LG (+1 bullish, -1 bearish), 3 BOS (+1 up, -1 down), 4 HTF BSL edge, 5 HTF SSL edge, 6 HTF LG, 7 HTF BOS.
Chart-timeframe values are written for closed candles only (the forming candle holds EMPTY_VALUE in buffers 0-3). HTF values on the forming candle are final because they come from a closed HTF candle. When passing inputs through iCustom, pass an empty string in place of each input group (see the inputs list; checked on terminal build 6281).
ALERTS
- Eight switches: LG bullish / LG bearish / BOS up / BOS down, each for the chart timeframe and for the higher timeframe; popup and/or push notification (push requires push notifications enabled and your MetaQuotes ID in Tools - Options - Notifications; if push is on but the terminal cannot send it, the indicator says so once in a popup).
- One message per closed candle, sent on the first tick after the candle closes; several chart-timeframe events of the same candle are joined in one message. A higher-timeframe event is sent as its own message on the first tick after the higher-timeframe candle closes. Push messages are cut at 255 characters.
- Events from history never alert, including the first calculation after the indicator is attached and the HTF catch-up when HTF history arrives. After the terminal reloads the chart history, alerts resume with the most recently closed candle; older candles that closed during the reload are drawn but not alerted, so nothing is repeated.
- A chart-timeframe candle that closed long before the tick that reports it (the terminal was idle, the market was closed) is drawn but not alerted; this includes the last candle before a weekend or a daily trading break. Higher-timeframe events are not filtered this way: the first tick after the higher-timeframe candle closes alerts, also after a weekend.
INPUTS
- Structure: Swing strength (1-50).
- Liquidity grab (LG): Displacement x ATR, Confirm window (bars).
- Quality filters: Min sweep depth x ATR, Min rejection (0-1), Cooldown per side (bars), Equal-level tolerance x ATR.
- Break of structure (BOS): BOS marks - direction changes / all breaks / off.
- Higher timeframe: Current = automatic, or any period above the chart period.
- Display: LG marks, BOS marks, edge tags, status line, mark font size (6-14), marks kept on the chart (10-1000), history bars to calculate (200-100000), Instance ID.
- Alerts (new closed bars only): eight event switches, popup, push.
NOTES
- Up to 200 most recent marks are kept (adjustable); older marks are removed as new ones appear. The edge lines are indicator buffers and cover the whole calculated history.
- Instance ID lets you run several copies on one chart, for example with different swing strengths or higher timeframes: give each copy its own ID. A second copy with the same ID waits up to 3 seconds for the previous copy to close, then reports the duplicate and stays idle. An Expert Advisor loading the indicator with iCustom on the same chart needs an ID different from the chart copy.
- The first calculation of the default 5000 bars takes a fraction of a second; the time is printed in the Experts log. With 100000 history bars on M1 the HTF layer needs the corresponding H1 history, which the terminal downloads on first use.
- In the Strategy Tester the HTF layer uses the history the tester has loaded; alerts are not sent in the tester.
- On a monthly chart the HTF layer is off (MetaTrader has no quarterly period).
- The indicator does not trade and gives no trading recommendations. Results depend on the broker's price feed and on the history loaded in the terminal.
- This is the author's own Liquidity Zones [Zen] and Liquidity Zones MTF [Zen] logic implemented in MQL5.
Tested on MetaTrader 5 build 6281 against the author's reference implementation on EURUSD, XAUUSD and BTCUSD history (M5-D1), including live popup alerts on a demo account.
