MT5 as an EA cockpit — the 4 layers every automation needs
MetaTrader 5 is not just a charting app. It is a full execution stack — data feed, strategy engine, risk filters, and order routing — all running simultaneously under one window. This lesson maps each layer so you know exactly where to look when something goes wrong.
अंतिम समीक्षा:
The 60-second version
MT5 is not just a charting app — it's a full execution stack. Each layer can fail independently. Knowing the stack means you diagnose in minutes, not days.
- MT5 has 10 million+ active accounts (2024) — it won because it runs a full execution stack, not just charts
- Layer 1 (Data Feed): if your ticks are stale, every calculation downstream is wrong
- Layer 2 (Strategy Logic): your EA lives here — the MQL5 code you load via the Navigator panel
- Layer 3 (Risk Filters): position sizing, news blackouts, drawdown limits — all configurable via EA inputs
- Layer 4 (Order Engine): execution quality depends on your connection latency, not your strategy logic
When MetaQuotes crossed 10 million active MT5 accounts in 2024, the milestone was driven not by retail chart-reading but by institutional and prop-firm EA automation demand.
MetaQuotes ने 2024 में 10 million रजिस्टर्ड MT5 accounts की घोषणा की — prop-firm अपनाने, EM brokers के MT4 से माइग्रेशन, और iOS/Android ऐप के डेस्कटॉप के बराबर फ़ीचर तक पहुँचने से प्रेरित।
स्रोतMT5 Layers Explorer
Click any layer to see what it does, where to find it in MT5, and what failure mode to look for.
MT5's 4-layer execution stack
Why MT5 won the professional automation race
In aviation, the cockpit of a commercial aircraft is not simply a windshield with some buttons — it is a layered system where avionics reads sensor data, the flight management computer runs navigation logic, autopilot filters and overrides, and the control surfaces execute the final commands. A pilot who understands every layer can diagnose any anomaly mid-flight. A pilot who only knows how to follow procedures is helpless when the unexpected happens.
MetaTrader 5 is architected the same way. When MetaQuotes released MT5 in 2010, the key architectural difference from MT4 was not the interface — it was the addition of a multi-threaded tick processor, a built-in economic calendar, and a fundamentally redesigned order model that supports hedging, netting, and partial fills natively. These were not features for retail chart traders; they were features for professionals running automated systems around the clock.
By 2024, MT5 had crossed 10 million active accounts — a milestone driven primarily by prop firms, institutional desks, and independent EA developers who needed the execution reliability that MT5's layered architecture provides. Understanding that architecture is the first step in using the platform as a craftsperson rather than a passenger.
The 4-layer stack — data → strategy → risk → execution
Layer 1 — Market Data Feed. This is the foundation. MT5 receives a continuous stream of tick data from your broker's server: every bid/ask price update, every volume figure, every spread widening event. You view this layer through Market Watch (Ctrl+M). If you see a symbol grayed out or showing a stale timestamp, Layer 1 has a problem — and every computation in Layers 2–4 built on that symbol will be wrong.
Layer 2 — Strategy Logic (MQL5 EA). Your EA lives entirely in this layer. It reads the tick data from Layer 1, applies indicators, evaluates conditions, and produces a decision: open long, open short, close position, or do nothing. You interact with this layer through the Navigator panel (Ctrl+N) and the Expert Journal tab, which logs every decision the EA makes. This is where your trading edge either exists or doesn't.
Layer 3 — Risk Management Filters. Before any signal from Layer 2 becomes an actual order, it passes through a set of gates: Is the lot size within account equity limits? Is there a high-impact news event blocking trades? Has the daily drawdown limit been reached? These filters are configured in the EA's Inputs panel (double-click the EA in Navigator → Inputs tab). A well-built EA makes all risk parameters configurable; a poorly built one hard-codes them.
Layer 4 — Order Execution Engine. Once a signal passes all risk gates, MT5's order router sends it to the broker's server. The Terminal (Ctrl+T) shows every order, position, and trade history. This layer's performance is determined by network latency (the ping to your broker's server), the broker's execution model (market execution vs instant execution), and the liquidity available at the moment of the order. Your strategy logic has no influence over what happens here — which is why choosing a broker with low-latency infrastructure matters as much as choosing a good strategy.
Where things go wrong at each layer
Experienced EA operators know that nearly every live-performance problem has a specific layer of origin. Training yourself to think in layers reduces a vague 'my EA isn't working' complaint into a precise diagnostic question.
Layer 1 failures look like: EA not trading when it should, all trades at the wrong price, backtests diverging wildly from live results. Root cause: tick data quality. Check the Market Watch symbol for last update time and spread. Run a tick data quality report in the Strategy Tester (the 'Quality' column in the tester's Results tab).
Layer 2 failures look like: EA trading the wrong direction, missing obvious signals, or generating conflicting signals. Root cause: logic error or indicator misconfiguration. Check the Expert Journal for EA log messages. Most well-built EAs print their decision at every evaluation.
Layer 3 failures look like: EA not trading even though the signal is correct, or trading with unexpected lot sizes. Root cause: a risk gate is blocking or miscalculating. Open the EA Inputs and verify every risk parameter. Check if the news filter is blocking trades due to an event on the calendar.
Layer 4 failures look like: slippage far from expected levels, partial fills, or orders rejected. Root cause: execution infrastructure. Check the Terminal's Trade tab for execution speed (time between order sent and fill received). Compare your broker's average execution time against their published specification.
Key terms
A story from 2024
The 10 million account milestone MetaQuotes announced in 2024 tells a story not about retail chart traders, but about the professionalization of algorithmic trading.
MetaQuotes ने 2024 में 10 million रजिस्टर्ड MT5 accounts की घोषणा की — prop-firm अपनाने, EM brokers के MT4 से माइग्रेशन, और iOS/Android ऐप के डेस्कटॉप के बराबर फ़ीचर तक पहुँचने से प्रेरित।
The bulk of that growth came from prop firms — companies that fund traders and EAs with capital in exchange for a profit split. These firms run EAs on hundreds of accounts simultaneously, often on VPS infrastructure co-located near broker servers to minimise Layer 4 latency. Their operators cannot afford to think of MT5 as 'software' — they think of it as infrastructure, the same way a server engineer thinks of a database. Understanding the 4-layer architecture is what separates operators who can maintain and improve their system from those who can only hope it keeps working.
स्रोतPractice
Navigate the 5 essential MT5 windows
Open MT5 on a demo account. You are going to physically locate each of the 5 diagnostic windows that map to the 4 layers. Do not read ahead — find each one, spend 30 seconds observing it, then continue.
- 1
Market Watch (Ctrl+M) — Layer 1. Find EURUSD in the list. Right-click it and select 'Chart Window.' You now see real-time bid/ask prices streaming in. This is your Layer 1 feed. Note the spread: if it's above 3 pips during London session hours, your broker's data feed quality is worth investigating.
- 2
Navigator (Ctrl+N) — Layer 2 access point. Expand the 'Expert Advisors' section. You'll see all compiled EAs available. Drag the built-in 'Moving Average' EA onto the EURUSD H1 chart. Accept the default settings. A small face icon will appear in the top-right corner of the chart — this means the EA is active and evaluating Layer 2 logic every tick.
- 3
Terminal → Experts tab — Layer 2 journal. Click the Terminal button (Ctrl+T) at the bottom of the screen and select the 'Experts' tab. You will see timestamped log entries from the Moving Average EA. Every time the EA evaluates a condition, it can write here. This is your primary Layer 2 diagnostic feed.
- 4
Strategy Tester (Ctrl+R) — Layer 1+2 testing bench. Open the Strategy Tester. In the drop-down select 'Moving Average.' Set the date range to the last 3 months and click 'Start.' Watch it run. The Results tab shows each trade; the Graph tab shows the equity curve; the Quality row shows tick data completeness. Low quality (<90%) means Layer 1 backtesting data was incomplete.
- 5
MetaEditor (F4) — Layer 2 source. Open MetaEditor. Press Ctrl+O and navigate to the Experts folder. Open 'Moving Average.mq5.' You are now looking at the MQL5 source code of an actual EA. You don't need to understand every line yet — just locate the OnTick() function, which is where Layer 2 logic fires on every price update.
Mastery check
Four questions. Pass at 75% (3/4). Each question tests one of the 4 layers.
Mastery check — Lesson 2
4 प्रश्नों के साथ अपनी समझ परखें। पास होने के लिए 75/4 सही चाहिए।
Reflect
चिंतन
अपने ईमानदार उत्तर लिखें — केवल इसी डिवाइस पर सहेजे जाते हैं। अगले सप्ताह इनका उपयोग अपनी ट्रेडिंग सोच में पैटर्न पहचानने के लिए करें।
Pro deep dive
The 4-layer model is a useful mental framework. The actual MT5 execution architecture has additional complexity worth understanding if you plan to run EAs at any serious scale.
MetaQuotes' multi-threaded tick processing architecture
MT5 processes ticks on a dedicated thread pool separate from the UI thread — a fundamental architectural difference from MT4, which ran everything on a single thread. In practice this means an MT5 EA's OnTick() function can execute while the chart is rendering, while other EAs on other symbols are processing their own ticks, and while the order router is managing an open position. For the vast majority of retail EAs this makes no difference. For high-frequency strategies, scalpers, and news-reaction EAs, this concurrency model matters: you can run multiple EAs on multiple symbols without one blocking another, provided your VPS has sufficient CPU cores to service the thread pool. The MetaTrader 5 Technical Reference documents the thread model under 'Multi-currency Expert Advisors.' A key implication: MQL5 global variables (not to be confused with MT5 global variables) must be protected with MutexLock() in multi-EA scenarios to avoid race conditions.
Why MT4 EAs don't port cleanly to MT5
The most common misconception among traders upgrading from MT4 is that MQL4 EAs can be recompiled in MT5 with minor changes. In practice, the differences are architectural, not syntactic. MT4 uses a position-based accounting model where each order is independent. MT5 uses a deal-based model where positions are aggregated by symbol (in netting mode) or maintained separately (in hedging mode). An MT4 EA that opens multiple orders on the same symbol expecting independent position management will behave completely differently on MT5's netting broker. Additionally, the OrderSend() function signature changed: MT5 uses MqlTradeRequest / MqlTradeResult structures, and the order type constants were renamed. Beyond syntax: MT4 indicators are not compatible with MT5 — they must be rewritten. The OnTick / OnBar distinction (MT5 separates these cleanly; MT4 conflates them) also requires logic restructuring. Budget significant rewrite time for any MT4 → MT5 port, not just a recompile.
OnTick vs OnBar: execution contexts and their performance implications
MQL5 EAs can process market events in two primary contexts. OnTick() fires on every price update — potentially hundreds of times per second during news events. It provides maximum responsiveness but at a computational cost: code inside OnTick() runs on every single quote. OnBar() (implemented via ChartEvent or by checking if a new bar has formed at the start of OnTick()) fires only when a new candle completes — at most once per timeframe period. The right choice depends on strategy: mean-reversion scalpers and HFT approaches need OnTick precision; trend-following and swing strategies typically need only OnBar frequency and should explicitly avoid running heavy calculations on every tick. A common performance mistake is running iMA(), iBands(), or other indicator functions inside OnTick() without caching the result — this triggers a full indicator recalculation per tick, which is 100–1,000x more computation than necessary. Professional EA codebases cache indicator handles in OnInit() and only update cached values inside OnTick() when the bar index changes.
Execution infrastructure: the latency stack beyond Layer 4
Layer 4 in our model represents the MT5 order router. Below that, there is an infrastructure stack most retail traders never see: the VPS network path to the broker → the broker's FIX gateway → the broker's liquidity aggregator → the tier-1 liquidity provider's matching engine. IC Markets, for example, operates a data centre in Equinix SY3 Sydney for their MT5 server — co-located traders with a VPS in the same rack measure execution round-trips of under 1ms. Retail traders connecting from a home broadband connection in a different continent measure 80–200ms round-trips. For a daily-timeframe trend EA, this difference is irrelevant. For a scalper targeting 3-pip profits with a 1-pip spread, a 200ms delay means the fill has already moved. The 2024 IC Markets latency benchmarks (FX Blue data) show a median fill of 0.083 seconds for institutional co-located accounts vs 0.74 seconds for remote retail connections to the same server — a 9x difference. Lesson 8 of this course covers infrastructure setup for EA deployment.
Sources
उत्तर दिखाएं
Layer 1 (Market Data Feed) → Market Watch; Layer 2 (Strategy Logic / MQL5 EA) → Expert Journal + Navigator; Layer 3 (Risk Management) → EA Inputs panel; Layer 4 (Order Execution Engine) → Terminal Trade/History tabs.
केवल शैक्षिक सामग्री — निवेश सलाह नहीं। ट्रेडिंग में पूंजी हानि का जोखिम होता है। हमेशा डेमो पर अभ्यास करें और स्टॉप-लॉस का उपयोग करें। ← Automated Trading पर वापस