Supply Demand Zone Edge
- Experts
- Versione: 7.0
- Attivazioni: 5
Supply and demand zone Expert Advisor for MetaTrader 5
Overview
SD Master is a price-action Expert Advisor that trades supply and demand zones on XAUUSD (Gold). It identifies zones from impulsive price legs, filters them with a higher-timeframe trend bias, and enters only after a confirmed change of character (CHoCH). Every trade has a hard stop-loss anchored to the zone edge or structure, and position size is calculated from a fixed fractional risk with a mandatory maximum-risk ceiling.
The EA is designed for one position at a time. It never averages down, never uses a martingale grid, and never opens a position that would exceed the configured risk cap. If the minimum lot size already breaches the risk cap, the signal is skipped.
Recommended instrument: XAUUSD (Gold) Recommended timeframe: M15 Account types: Hedging and netting, ECN and standard Minimum deposit: 5,000 USD recommended (see Risk section for why)
How it works
1. Zone detection
The EA scans the last InpLookback bars for consolidation areas followed by impulsive moves. A valid zone requires a low-body (indecision) candle and a subsequent impulse of at least InpImpulseATR × ATR with a body of at least InpImpulseBody of its range. Zones expire after InpZoneMaxAge bars.
2. Trend alignment
Zones are filtered against the lower-timeframe swing structure ( InpSwingPeriod ) and optionally against a higher timeframe ( InpHTFTimeframe , default Daily) over InpHTFLookback bars. Range conditions can be allowed or blocked with InpAllowRange .
3. Entries
Two entry methods run in parallel:
- Confirmation entry ( InpUseConfirmation ): after a zone is touched, the EA waits up to InpConfirmMaxBars bars for a CHoCH, then enters at market on the confirming bar close. This is the primary method.
- Extreme-zone limit entry ( InpUseExtremeLimit ): places a limit order at the proximal or distal zone edge ( InpEntryEdge ) without waiting for confirmation.
The retracement-limit mode ( InpCEEntryMode ) and structural stop anchor ( InpSLAnchor ) are available but left off by default.
Two additional pattern modules are included but disabled by default: liquidity-sweep entries ( InpUseSweepEntry ) and the imbalance / fair-value-gap magnet filter ( InpUseImbalanceFilter ). They can be enabled independently for experimentation.
4. Stops and targets
Stop-loss sits beyond the zone edge plus an ATR buffer (buys use a wider buffer, see InpBuySLBufferATR ). Take-profit targets the next opposing zone. A minimum reward:risk of InpMinRR is enforced; if no valid target clears it, the setup is rejected.
5. Risk and money management
lots = floor_to_step( balance × InpRiskPercent% / ( |entry − SL| × tick_value / tick_size ) )
If the resulting risk exceeds InpMaxRiskPercent , the trade is skipped. This is the core safety rule: the EA does not increase lot size beyond its risk ceiling to force a trade.
Why the minimum deposit matters: with a 0.01-lot minimum on Gold, the smallest possible dollar risk equals the stop distance in dollars. Median stop distance in testing was about $16, with the 90th percentile near $59 and the maximum near $146. With a 1.5% risk ceiling, a $1,000 account can only risk $15 — so more than half of all signals are skipped, and the skipped ones are disproportionately the larger stop-distance setups. A $5,000 account skips essentially none.
6. Time and session filters
- InpUseSessionFilter blocks the thin Asian session (server hours InpSessionBlockFrom to InpSessionBlockTo ).
- InpUseFridayCutoff deletes pending orders and blocks new exposure late on Friday ( InpFridayCutoffHour ).
Installation
- Attach the EA to an XAUUSD M15 chart.
- Allow automated trading and, if your broker requires it, WebRequest is not needed — the EA uses no external network calls and no DLLs.
- Load the supplied .set file (SD_Master v7) or enter the recommended parameters below.
- Let the EA run continuously; it evaluates setups on newly closed bars.
- Verify the magic number ( InpMagic ) does not conflict with another EA on the same account.
Backtesting: use real tick data ("Every tick based on real ticks") for meaningful results. The EA internally uses the current-chart timeframe ATR and higher-timeframe series; make sure the higher timeframe data is available in the terminal.
Recommended settings
| Parameter | Value | Notes |
|---|---|---|
| Timeframe | M15 | |
| Symbol | XAUUSD | |
| InpRiskPercent | 1.0 | Conservative default |
| InpMaxRiskPercent | 1.5 | Hard ceiling |
| InpConfirmMaxBars | 30 | Confirmation window |
| InpMinRR | 2.2 | Minimum reward:risk |
| InpImpulseATR | 1.20 | Impulse strength |
| InpZoneMaxAge | 200 | Zone lifetime in bars |
| InpHTFTimeframe | D1 | Higher-timeframe filter |
| InpUseHTFFilter | true | |
| InpBuySLBufferATR | 0.75 | |
| InpCEEntryMode | CE_MARKET | Additional modes optional |
| InpSLAnchor | SL_ZONE_ATR | |
| InpUseSweepEntry | false | Optional module |
| InpUseImbalanceFilter | false | Optional module |
| InpMagic | 20261019 | Change if another EA uses this |
| InpComment | SD_v70 | Order comment prefix |
A more aggressive profile can be created by setting InpRiskPercent = 2.0 and InpMaxRiskPercent = 3.0 . Risk per trade is always a percentage of current balance, so it compounds.
Full parameter reference
Zone Detection
| Parameter | Default | Description |
|---|---|---|
| InpLookback | 400 | Bars scanned for zones |
| InpIndecisionBody | 0.40 | Max body/ATR ratio for a base candle |
| InpMinCandleATR | 0.30 | Minimum candle ATR |
| InpImpulseATR | 1.20 | Impulse size in ATR |
| InpImpulseBody | 0.60 | Impulse body fraction |
| InpImpulseMaxBars | 3 | Max bars for the impulse leg |
Zone Validity
| Parameter | Default | Description |
|---|---|---|
| InpZoneMaxAge | 200 | Bars before a zone expires |
Trend Filter
| Parameter | Default | Description |
|---|---|---|
| InpSwingPeriod | 2 | Swing points used for CHoCH |
| InpAllowRange | false | Allow range conditions |
Higher-Timeframe Filter
| Parameter | Default | Description |
|---|---|---|
| InpUseHTFFilter | true | Enable HTF bias |
| InpHTFTimeframe | D1 | HTF period |
| InpHTFLookback | 300 | HTF bars scanned |
Extreme Zone Limit Entry
| Parameter | Default | Description |
|---|---|---|
| InpUseExtremeLimit | true | Enable limit entries at zone edges |
| InpEntryEdge | PROXIMAL | Proximal or distal edge |
Confirmation Entry
| Parameter | Default | Description |
|---|---|---|
| InpUseConfirmation | true | Enable CHoCH confirmation entries |
| InpConfirmMaxBars | 30 | Bars a zone waits for confirmation |
| InpMaxWatches | 6 | Concurrent zone watches |
Entry Refinement (optional)
| Parameter | Default | Description |
|---|---|---|
| InpCEEntryMode | CE_MARKET | Market / retracement limit / limit with fallback |
| InpCERetraceMaxBars | 12 | Retracement limit lifetime |
| InpSLAnchor | SL_ZONE_ATR | Zone edge+ATR / structural extreme |
Liquidity Sweep Entry (optional, off)
| Parameter | Default | Description |
|---|---|---|
| InpUseSweepEntry | false | Enable sweep patterns |
| InpSweepRequireZone | true | Swept level must overlap a live zone |
| InpSweepCloseBack | true | Require close back inside |
| InpSweepMaxBars | 12 | Bars to wait for CHoCH |
| InpMaxSweepWatches | 4 | Concurrent sweep watches |
Imbalance Magnet Filter (optional, off)
| Parameter | Default | Description |
|---|---|---|
| InpUseImbalanceFilter | false | Skip zones with an unfilled gap beyond them |
| InpImbLookback | 200 | Bars scanned for gaps |
| InpImbMinSizeATR | 0.10 | Minimum gap size |
Buy-side Hardening & Sessions
| Parameter | Default | Description |
|---|---|---|
| InpBuySLBufferATR | 0.75 | Buy stop buffer |
| InpBuyConfirmOnly | false | Buy confirmation-only mode |
| InpUseSessionFilter | true | Block thin Asian hours |
| InpSessionBlockFrom | 0 | Block from hour (server) |
| InpSessionBlockTo | 8 | Block to hour (server) |
Friday Cutoff
| Parameter | Default | Description |
|---|---|---|
| InpUseFridayCutoff | true | Block late-Friday exposure |
| InpFridayCutoffHour | 22 | Cutoff hour (server) |
Targets
| Parameter | Default | Description |
|---|---|---|
| InpUseZoneTargets | true | Target the next opposing zone |
| InpMinRR | 2.2 | Minimum reward:risk |
| InpRR | 3.0 | Fallback fixed R:R |
Liquidity Filter
| Parameter | Default | Description |
|---|---|---|
| InpUseLiquidity | true | Avoid entries near obvious liquidity |
| InpLiqLookback | 150 | Bars scanned |
| InpLiqToleranceATR | 0.15 | Tolerance in ATR |
Risk
| Parameter | Default | Description |
|---|---|---|
| InpRiskPercent | 1.0 | Target risk per trade, % balance |
| InpMaxRiskPercent | 1.5 | Hard ceiling; trade skipped if exceeded |
| InpFixedLots | 0.0 | Fixed lot override (0 = percent mode) |
| InpSLBufferATR | 0.25 | Sell stop buffer |
| InpMagic | 20261019 | Magic number |
| InpComment | SD_v70 | Order comment prefix |
Important notes
- Past performance in a strategy tester is not indicative of future results. Any backtest equity curve shown on this page was produced in the MetaTrader 5 strategy tester and is labelled as such.
- This EA trades a single position at a time by design. It is not a grid, martingale, or hedging system.
- Always test on a demo account first and use a VPS for uninterrupted operation.
- The seller provides updates for compatibility with MetaTrader 5 platform updates and fixes for confirmed defects.
