Supply Demand Zones Base Impulse ATR MT4
- Indicators
-
Kazuma Uezono
MQL5 / MQL4 / Pine Script v6 developer and active trader.
Seller on the MQL5 Market (indicators for MT4/MT5).
Services:
- TradingView Pine Script to MT5/MT4 conversion (bar-by-bar matching, with tester report)
- MT4 to MT5 migration - Version: 1.1
Do you mark supply and demand zones by hand and get a slightly different result every time? This free MetaTrader 4 indicator draws them with one fixed rule that is written out in full below, so you can check every zone yourself.
The idea: a strong candle (body at least X times ATR) leaves a "base" of 1 to 10 small candles right before it. A bullish strong candle that closes above the base turns it into a demand zone; a bearish one that closes below it turns it into a supply zone. The indicator only displays these areas. It gives no buy or sell signals, places no orders, and a zone does not mean that price will react there.
How It Is Calculated
1. True Range of a candle = max(high, previous close) - min(low, previous close).
2. ATR = simple average of the True Range of the N candles before the strong candle (the strong candle itself is left out).
3. Strong candle = |close - open| of at least X x ATR.
4. Base = the run of candles directly before the strong candle whose body is at most Y x ATR, counted backwards up to the maximum. No small candle directly before it = no zone.
5. Edges = high and low of the base candles, or open/close only when "Bodies only" is selected.
6. Direction: bullish strong candle closing above the top = demand; bearish strong candle closing below the bottom = supply.
7. From the next candle on: a close beyond the far edge (below a demand zone, above a supply zone) marks the zone as broken. A candle that reaches the near edge counts as a touch, once per visit (it must have been outside on the candle before).
Everything is decided on closed candles. After a zone is created, its price range and start time stay fixed; only its state changes (fresh, touched N, broken).
Features
- Zone labels such as "Demand fresh", "Supply touched 3" or "Supply broken", and a tooltip with the two prices, the base size and the base start time.
- Separate colors for fresh and touched zones; broken zones are hidden or shown as grey outlines (your choice).
- Where two zones overlap, the older one keeps its fill and the newer one becomes an outline.
- Higher timeframe zones: pick one timeframe above the chart (off by default). They are drawn as thick outlines labelled with the timeframe, for example "D1 Demand touched 1".
- Alert when price moves into a fresh zone from outside, once per zone (off by default): pop-up, sound and/or push.
- Automatic label color for light and dark chart backgrounds. English or Japanese text.
Main Inputs (as listed in the MT4 dialog)
ATR period 14 | Strong bar X 1.5 | Base bar Y 0.5 (below X) | Base bars max 3 | Zone edges: wicks | Bars to scan 5000 | Unbroken zones per side 5 | Remove zones older than 1000 bars (0 = never) | Broken zones: hide | Broken zones per side 3 | Extend right 10 bars | Labels on, size 8 | Colors: demand fresh, demand touched, supply fresh, supply touched, broken, label (None = auto) | Higher timeframe: current (= off) | HTF zones per side 3 | Alert on entering a fresh zone: off | Pop-up on, sound off, push off | Language: Auto
Values outside the ranges shown in the dialog stop the indicator from loading.
Buffers for EAs
Six hidden buffers: 0 demand top, 1 demand bottom, 2 demand touches, 3 supply top, 4 supply bottom, 5 supply touches. Each closed candle stores the newest unbroken zone of each side at that close; shift 0 repeats shift 1. No zone (or a zone older than the age limit) = EMPTY_VALUE. Only chart-timeframe zones are stored; higher timeframe zones are not.
In iCustom pass the 26 inputs in the order of the dialog, then the buffer number and the shift:
ATR period, X, Y, base bars max, zone edges (0 wicks / 1 bodies), bars to scan, unbroken zones per side, age limit, broken zones (0 hide / 1 show), broken zones per side, extend bars, show labels, font size, the six colors, higher timeframe, HTF zones per side, alert on enter, pop-up, sound, push, language (0 auto / 1 English / 2 Japanese).
When called through iCustom the indicator does not draw, does not use a timer and raises no alerts; it only fills the buffers.
Notes and Limits
- A zone that the forming candle has entered still reads "fresh" until that candle closes; the touch is counted at the close.
- The alert itself is checked tick by tick against the zones of the last closed candle, so it may arrive before the label changes. The first price after loading is only stored, not alerted.
- Only the last "Bars to scan" candles are calculated. When MT4 reloads the chart (more history, reconnection, new input values) the scan starts again, so the oldest zones may come out differently; recent ones stay the same.
- Different inputs or a different broker's prices give different zones. Quiet sideways markets can produce many small zones, and in strong trends zones are often broken quickly.
- Fresh status and touch counts are history, not odds.
- A second copy on the same chart draws outlines only, so it does not wipe out the fills of the first.
- Strategy Tester: in visual mode the zones are drawn as on a live chart; no alerts are raised in the tester. Higher timeframe zones can make the tester journal print the terminal's own "history cache" messages, which are not indicator errors. Very large display settings slow the tester down.
- Chart objects use the prefix "SDZ#"; temporary global variables use "SDZ_". Both are cleaned up on removal. Chart settings are left as they are.
Compatibility and Support
- MetaTrader 4 only (an MT5 version is available separately, also free). Any symbol, any timeframe; works with templates and after a restart.
- No DLLs, no internet connection, no files.
- Questions about installation, settings or bugs: send an MQL5 message. Market forecasts and trade advice are outside the support scope.
- This indicator is a charting aid. It does not guarantee any trading result, and past chart behaviour does not guarantee future behaviour.
