Supply and Demand Indicator for MT5 mapping institutional zones.
The Supply and Demand MT5 Indicator is a free, high-performance tool built for MetaTrader 5. It utilizes native MQL5 multi-threaded processing to map fresh and tested supply/demand zones with real-time mobile push notifications.
Supply and Demand MT5 Indicator Overview
Advanced Supply and Demand Analysis on MetaTrader 5
The Supply and Demand MT5 Indicator harnesses the 64-bit multi-core architecture of MetaTrader 5 to deliver real-time institutional zone mapping with zero terminal lag. In modern market microstructure, price movement is driven entirely by aggressive market orders matching resting limit orders. When large institutions execute size, the resulting volume imbalance creates distinct supply and demand zones that dictate upcoming price behavior.
This indicator automates the process of locating Drop-Base-Rally (DBR), Rally-Base-Drop (RBD), Rally-Base-Rally (RBR), and Drop-Base-Drop (DBD) bases across multiple timeframe layers, calculating zone freshness, volume displacement ratios, and sending instant mobile push alerts directly to your smartphone.
Core Institutional Formations Detected by MQL5
Drop-Base-Rally (DBR)
A major institutional accumulation base that forms at market bottoms, reversing a downward trend into an aggressive bullish rally.
Rally-Base-Drop (RBD)
A major institutional distribution base that forms at market tops, reversing an upward trend into an aggressive bearish drop.
Rally-Base-Rally (RBR)
A continuation demand base formed during strong bullish trend impulses where institutions add to existing winning long positions.
Drop-Base-Drop (DBD)
A continuation supply base formed during aggressive downward trend expansions where institutional sellers add new short volume.
Zone Freshness & Retest Classification
| Classification | Retest Count | Success Rate | Recommended Action |
|---|---|---|---|
| Fresh (Unmitigated) | 0 touches | 80%+ Probability | Primary entry setup; place limit or lower-timeframe confirmation orders. |
| Tested (Mitigated) | 1 touch | 55-65% Probability | Trade with caution; require strict lower-timeframe CHoCH confirmation. |
| Exhausted | 2+ touches | <40% Probability | Avoid entries; expect breakout through the distal line. |
MQL5 Native Multi-Threaded Engine Architecture
The MetaTrader 5 edition is written in native object-oriented MQL5, featuring significant performance enhancements over legacy MQL4 code:
- Tick-by-Tick Processing: Evaluates incoming real tick volume data without lag, ensuring instantaneous zone touch alerts.
- Graphic Object Cache: Uses optimized graphical rectangle caching to ensure charts scroll smoothly even with 500+ historical zones plotted.
- Multi-Timeframe Buffer Arrays: Employs dynamic indicator plot buffers allowing seamless integration with MetaTrader 5 Expert Advisors (EAs).
- Push Notification Server: Sends zero-delay push alerts to iOS and Android smartphones via MetaQuotes ID integration.
Supported MT5 Timeframes & Execution Strategies
| Timeframe | Trading Style | Strategic Purpose |
|---|---|---|
| M1 / M2 / M3 / M5 | High-Frequency Scalping | Fine-tuned precision entry timing on micro-structure zone bounces. |
| M15 / M30 | Intraday Session Trading | Mapping London and New York session liquidity expansion zones. |
| H1 / H2 / H4 | Day & Swing Trading | Identifying primary institutional trend bias and major supply/demand levels. |
| D1 / W1 / MN | Position / Macro Trading | Macro institutional asset allocation and multi-month reversal barriers. |
Key Features & Capabilities
Input Parameters & Settings Guide
Configure the indicator inputs inside MetaTrader MT5 via the Inputs tab upon attaching to your chart:
| Parameter | Default Value | Description | Recommended |
|---|---|---|---|
| InpZoneStrength | 3 | Zone fractal sensitivity (1-5) | 3 for Intraday, 4-5 for Swing |
| InpZoneLookback | 200 | Lookback bar calculation depth | 200-500 bars |
| InpDemandColor | clrDarkGreen | Demand zone fill color | Dark Green / Emerald |
| InpSupplyColor | clrMaroon | Supply zone fill color | Maroon / Crimson |
| InpPushAlerts | true | Send alerts to MT5 mobile app | True |
Trading Strategy & Entry Rules
Step 1: Multi-Timeframe Alignment
Locate fresh H4 or Daily supply and demand zones to establish the macro institutional trend direction.
Step 2: Monitor Price Approach
Wait patiently for price to pull back cleanly into the untested zone without chasing extending market moves.
Step 3: Confirm with Lower Timeframe Structure
On M5 or M15, watch for reversal candlestick structures, rejection wicks, or a structural Change of Character (CHoCH) shift before executing.
Step 4: Manage Invalidation and Targets
Place your protective stop loss 5-10 pips outside the distal edge of the zone and target the next opposing liquidity pool for a 1:3+ risk-to-reward ratio.
MQL5 Source Code
//+------------------------------------------------------------------+
//| SupplyDemand_Zones_MT5.mq5 |
//| Copyright 2026, TraderSentiments Quant Team |
//| https://tradersentiments.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2026, TraderSentiments"
#property link "https://tradersentiments.com/indicators/mt5/smart-money/supply-demand-indicator"
#property version "2.00"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots 2
input int InpZoneStrength = 3; // Zone Strength (1-5)
input int InpZoneLookback = 200; // Lookback Bars
input color InpDemandColor = clrDarkGreen;// Demand Color
input color InpSupplyColor = clrMaroon; // Supply Color
input bool InpPushAlerts = true; // Mobile Push Alerts
int OnInit() {
IndicatorSetString(INDICATOR_SHORTNAME, "Supply & Demand Zones MT5");
return(INIT_SUCCEEDED);
}How to Install & Compile in MetaTrader MT5
Follow this complete step-by-step technical guide to install, compile, and configure the custom MQL5 indicator on your desktop trading terminal:
Download Source File
Download the raw .mq5 source file to your computer using the direct download button below.
Open MT5 Data Folder
Open your MetaTrader terminal, navigate to the top menu bar, click File → Open Data Folder, and open the MQL5 → Indicators subfolder.
Copy & Compile in MetaEditor
Paste the downloaded file into the Indicators directory. Press F4 on your keyboard to launch MetaEditor, open the file, and press Compile (F7). Ensure the compiler reports 0 errors and 0 warnings.
Attach to Chart & Configure
Return to your terminal, refresh the Navigator (Ctrl+N) panel, drag the indicator onto your active chart, check Allow DLL imports (if applicable), and customize input parameters.
Integrating with Expert Advisors (EA) via iCustom()
Algorithmic traders and quant developers can seamlessly integrate this indicator into custom automated Expert Advisors (EAs). Because the indicator calculates values into standardized plot buffers on closed bars, you can query buffer values using native MQL5 functions without recompilation:
// MT5 MQL5 iCustom Calling Syntax Example
int indicatorHandle = iCustom(_Symbol, _Period, "SupplyDemand_Zones_MT5");
double buyBuffer[1], sellBuffer[1];
CopyBuffer(indicatorHandle, 0, 1, 1, buyBuffer);
CopyBuffer(indicatorHandle, 1, 1, 1, sellBuffer);
if (buyBuffer[0] != 0.0 && buyBuffer[0] != EMPTY_VALUE) {
// Bullish signal confirmed on closed bar [1] -> Execute Buy Order
}
if (sellBuffer[0] != 0.0 && sellBuffer[0] != EMPTY_VALUE) {
// Bearish signal confirmed on closed bar [1] -> Execute Sell Order
}How to Set Up Mobile Push Notifications on iOS & Android
To receive real-time push alerts on your smartphone whenever an institutional signal triggers:
- Install the official MetaTrader MT5 app on your iPhone or Android smartphone.
- Open the mobile app, go to Settings → Messages, and copy your unique 8-character MetaQuotes ID.
- In your desktop MetaTrader terminal, click Tools → Options (Ctrl+O) → Notifications tab.
- Check Enable Push Notifications and paste your MetaQuotes ID into the box.
- Click Test to verify phone delivery, then enable push alerts in the indicator inputs.
Institutional Risk Management & Capital Preservation Protocol
Professional proprietary trading desks operate under strict risk control parameters to ensure longevity:
- Maximum 1% - 2% Risk Rule: Never risk more than 1% to 2% of total account equity on any individual trade setup.
- Minimum 1:2.5 Risk-to-Reward Ratio (RRR): Only execute setups where the potential profit target is at least 2.5 times greater than the stop-loss invalidation distance.
- Multi-Timeframe Confluence Required: Never take an intraday trade against the primary Daily or 4-Hour trend direction.
- High-Impact Economic News Awareness: Avoid entering new positions 15 minutes before and after major macroeconomic data releases (such as US Non-Farm Payrolls, CPI Inflation, and central bank FOMC/ECB interest rate announcements).
Strategy Backtesting & Historical Modeling Protocol
Before deploying any indicator or automated strategy in a live trading environment, professional quants conduct rigorous multi-year backtesting across varying market conditions:
- 99.9% Tick Data Modeling: Use high-precision tick history from reputable data providers (such as Dukascopy or TrueFX) to eliminate spread anomalies and slippage distortion.
- Spread & Commission Inclusion: Always test with realistic variable spreads and broker commission structures to simulate true real-world execution friction.
- Out-of-Sample Walk-Forward Optimization: Avoid curve-fitting by validating parameters on 70% in-sample data and testing robustness on 30% out-of-sample data.
- Monte Carlo Drawdown Analysis: Run randomized trade sequence simulations to calculate the maximum potential drawdown under adverse market volatility regimes.
Virtual Private Server (VPS) & Execution Latency Optimization
For active day traders, scalpers, and automated Expert Advisors, execution speed is paramount:
- Low-Latency Proximity Hosting: Deploy your MetaTrader MT5 terminal on a dedicated Windows VPS located in the same financial data center (e.g. Equinix LD4 in London or NY4 in New York) as your broker server to achieve sub-millisecond execution times.
- Terminal Memory Optimization: Go to Tools → Options → Charts and decrease Max bars in chart to 5,000 to conserve CPU and RAM resources.
- Audio & News Feed Disabling: Turn off unneeded terminal audio event chimes and background news feeds to ensure 100% of CPU cycles are dedicated to indicator calculations.
Common MetaTrader Error Codes & Resolution Matrix
| Error Code | Description | Exact Resolution Action |
|---|---|---|
| ERR_INVALID_STOPS (130) | Stop Loss or Take Profit is too close to current price. | Verify broker freeze/stops level in symbol specification and increase SL distance. |
| ERR_OFF_QUOTES (136) | Broker server has no available liquidity quotes. | Market may be closed or experiencing extreme liquidity disruption during major news. |
| ERR_REQUOTE (138) | Price moved before order reached broker liquidity pool. | Increase slippage tolerance deviation parameter in your order execution settings. |
| ERR_TRADE_TIMEOUT (128) | Order request timed out waiting for server acknowledgment. | Check internet connection latency or migrate terminal to a dedicated trading VPS. |
Institutional Quantitative Trading Lexicon
Broker Execution Models & Raw Spread Compatibility
To achieve optimal performance when using custom technical indicators:
- ECN / Raw Spread Accounts: Use True ECN accounts with 0.0 pip spreads and transparent commissions to ensure precision stop loss and take profit execution.
- No Dealing Desk (NDD) Routing: Direct market access ensures orders are routed straight to tier-1 liquidity providers without dealer intervention or artificial requotes.
- Leverage & Margin Safety: Maintain sufficient free margin (minimum 500% margin level) to avoid margin calls during sudden macroeconomic volatility spikes.
SupplyDemand_Zones_MT5.mq5
Version: v2.00File Size: 17.8 KBTotal Downloads: 15,000+License: Free Open SourcePlatform: MetaTrader MT5
Frequently Asked Questions

Quantitative algorithmic trading research desk specializing in MetaTrader MQL4/MQL5 automated systems, institutional order book mechanics, and risk management tools.
