Overview
An Expert Advisor is an automated trading program running within the MetaTrader platform — MT4 or MT5 — that monitors the market, generates trading signals, and executes orders without requiring manual intervention. For forex traders who have developed a strategy with a defined edge, an Expert Advisor converts that strategy from a discretionary process that depends on the trader's attention and discipline into an automated system that executes consistently, around the clock, across the currency pairs it is designed for.
The MetaTrader platform is the dominant execution environment for retail forex trading. The majority of retail forex brokers support MT4 or MT5, making Expert Advisors the most widely deployable form of automated forex trading available. A well-built Expert Advisor running on a VPS connected to a responsive broker can execute trades in milliseconds, manage positions precisely according to strategy rules, and operate continuously across Asian, European, and American sessions without the fatigue and attention failures that manual trading accumulates over time.
The quality of an Expert Advisor is determined by the precision of its strategy implementation, the robustness of its order management, its handling of the edge cases that live trading produces, and the reliability of its operation over extended periods. An Expert Advisor that works in backtesting but fails in live trading — because of order management errors, because it does not handle broker rejections correctly, because it accumulates position errors during connectivity interruptions — is not a working Expert Advisor. It is a strategy prototype that has not been finished.
We build custom Expert Advisors for forex traders who want their strategy automated, for proprietary trading firms deploying systematic strategies across MetaTrader accounts, and for strategy developers who need their algorithms implemented to a standard that will hold up in live trading conditions.
What Expert Advisor Development Covers
Strategy specification and MQL implementation. The Expert Advisor begins with the strategy — the precise definition of the entry conditions, the exit conditions, the position sizing logic, and the risk management rules that the EA will implement. Strategy specification converts the trader's description of their approach into the unambiguous, complete definition that MQL4 or MQL5 implementation requires.
MQL implementation translates the strategy specification into the Expert Advisor code — the OnTick() or OnBar() event handlers that process each price update, the signal generation logic that identifies entry and exit conditions, the order management functions that open, modify, and close positions, and the risk management checks that validate each trading action before execution.
MQL4 for MT4-based strategies — the established platform with the widest broker support. MQL5 for MT5-based strategies — the more capable platform with native support for hedging mode, netting mode, and the improved object-oriented MQL5 language that complex strategies benefit from. For traders whose broker supports only MT4 but whose strategy requires features better suited to MQL5, we implement the strategy in the MT4 context with the workarounds that MT4's limitations require.
Entry and exit logic. The signal generation code that identifies the market conditions under which the strategy enters and exits positions. Technical indicator-based entry conditions — moving average crossovers, RSI levels, Bollinger Band conditions, Stochastic signals, MACD crossovers — implemented with the indicator parameter configuration that the strategy specifies and the bar confirmation logic that prevents the false signals that unconfirmed bar conditions produce.
Price action-based entry conditions — candlestick pattern recognition, support and resistance level tests, breakout conditions — implemented with the pattern recognition code that identifies the specific formations the strategy trades. Custom indicator development for strategies whose signal logic uses indicators not available in the MetaTrader standard library or the public custom indicator repositories.
Multi-timeframe analysis — the higher-timeframe trend filter that determines whether the strategy is in a valid trading environment, combined with the lower-timeframe entry signal that identifies the specific entry point — implemented with the multi-timeframe data access that MQL provides and the synchronisation logic that ensures the higher-timeframe condition is evaluated on the correct bar.
Exit logic that handles the full range of exit scenarios: fixed stop loss and take profit levels set at the point of entry, trailing stops that follow price in the trade's direction while protecting accrued profit, breakeven stops that move the stop loss to entry price once a defined profit level is reached, time-based exits that close positions after a defined number of bars or at a specific time, and signal-based exits triggered by the reversal of the entry condition.
Order management. The order management layer that translates strategy decisions into MetaTrader order operations — the OrderSend(), OrderModify(), and OrderClose() calls in MT4, the trade request structures in MT5 — with the error handling that makes order operations reliable in live trading conditions.
Requote handling — the MT4 response when the broker cannot fill at the requested price — with the configurable retry logic that attempts execution at the new price within the strategy's defined slippage tolerance. Order rejection handling for the range of error codes that MetaTrader brokers return — invalid stops, insufficient margin, market closed, connection error — with the appropriate response to each error type.
Pending order management for strategies that use buy stops, sell stops, buy limits, or sell limits rather than market orders — placing pending orders at the correct price, modifying them when the strategy conditions change, and cancelling unfilled orders when they are no longer relevant.
Position modification logic that adjusts stop loss and take profit levels as the trade progresses — the trailing stop that moves the stop loss incrementally as the price moves in the strategy's favour, the breakeven adjustment that eliminates risk once a defined profit threshold is reached.
Risk management and position sizing. Position sizing logic that calculates the correct lot size for each trade based on the account's current equity, the defined risk percentage per trade, and the distance in pips from the entry price to the stop loss. Fixed fractional position sizing ensures that the dollar risk on each trade is a consistent percentage of account equity — the lot size is recalculated on every trade rather than fixed at a constant value.
Maximum position limits — the maximum number of concurrent open positions the EA will hold, the maximum total exposure in lots, and the maximum number of trades per day or per session — that prevent the strategy from accumulating excessive exposure in adverse conditions.
Drawdown protection — the daily or total drawdown limit that suspends EA trading when the account has lost a defined percentage, protecting remaining capital without requiring the trader to monitor the account continuously. The EA resumes trading automatically when the drawdown protection reset conditions are met, or requires manual restart depending on the strategy's risk management policy.
Correlation management for strategies trading multiple currency pairs simultaneously — detecting when multiple positions are open in highly correlated pairs and adjusting position sizes or blocking new entries to prevent the concentration risk that correlated positions create.
Broker compatibility and spread management. Not all MetaTrader brokers behave identically. Execution mode differences — market execution versus instant execution — affect how orders are placed and how requotes are handled. Spread variation across brokers — some brokers offer fixed spreads, others variable spreads that widen significantly during news events — affects the viability of strategies with tight profit margins. Minimum stop distance requirements that vary by broker and by market condition affect where stop losses can be placed.
Broker compatibility configuration — the parameters that adapt the EA's behaviour to the specific broker it is running on — allows the same EA to operate correctly across different brokers without code changes. Spread filters that prevent the EA from opening new trades when the spread exceeds a defined maximum protect strategy viability during high-spread periods.
News filter and session management. Forex markets are significantly affected by scheduled economic news releases — NFP, FOMC, CPI, ECB decisions — that cause sudden price moves and spread widening that strategy execution cannot anticipate or handle correctly. News filters that suspend EA trading around scheduled high-impact news events prevent the poor executions and erratic market behaviour during news periods from affecting the strategy.
Session filters that restrict EA trading to the specific forex sessions where the strategy's edge is present — the London session for strategies that depend on European liquidity, the overlap between London and New York for strategies that require the highest liquidity — prevent the strategy from trading in sessions where the market conditions are different from those the strategy was designed for.
Optimisation and parameter management. Expert Advisors with configurable parameters — the input variables that define the strategy's behaviour: indicator periods, stop loss distances, take profit multiples, risk percentages — allow the strategy to be optimised in the MetaTrader Strategy Tester using the built-in optimisation engine. Parameter input variable design that exposes the right parameters to optimisation while keeping the EA's internal logic encapsulated.
The MetaTrader Strategy Tester for backtesting — testing the EA against historical data at tick, bar, or OHLC accuracy, with the transaction cost configuration that realistic backtesting requires. Strategy Tester results that provide the performance statistics, the equity curve, and the trade list that strategy evaluation uses.
Logging and diagnostics. Comprehensive logging within the Expert Advisor — recording every signal evaluation, every order operation, every error encountered, and every risk management decision to the MetaTrader Expert log — provides the diagnostic record that post-trade analysis and debugging require. When an EA behaves unexpectedly in live trading, the log record is the primary source of information about what happened and why.
Alert generation for events that require the trader's attention — a large adverse move against an open position, a daily drawdown limit approaching, a connectivity interruption that may have affected order state — through MetaTrader's native alert system and optionally through email or push notification.
MT4 vs MT5 Expert Advisors
MT4 Expert Advisors. MT4 remains the most widely supported MetaTrader version among retail forex brokers. MT4 EAs are written in MQL4 — a language specifically designed for MetaTrader 4 trading automation. MT4 operates in hedge mode by default — multiple positions in the same instrument can be held simultaneously in the same direction or opposing directions, which simplifies the position management logic for strategies that stack positions or use hedging approaches. MT4's limitation is that MQL4 is less capable as a programming language than MQL5 — complex object-oriented structures are not supported, which limits the architectural complexity of MT4 EAs.
MT5 Expert Advisors. MT5 is the newer platform with the more capable MQL5 language — full object-oriented programming, better data structures, improved backtesting capabilities, and access to more financial instruments including stocks, futures, and options alongside forex. MT5 supports both hedging mode (configured by the broker) and netting mode (the default for most MT5 brokers) — strategies designed for hedging mode require adjustment to operate correctly in netting mode. MT5's improved Strategy Tester — with real tick data backtesting and multi-currency optimisation — produces more accurate backtesting results than MT4's tick simulation.
VPS Deployment and Live Operation
An Expert Advisor running on a trader's personal computer operates only when the computer is on, the MetaTrader platform is running, and the internet connection is stable. VPS (Virtual Private Server) deployment provides the always-on, low-latency environment that EA operation requires.
VPS selection for forex EA operation — choosing a VPS provider with servers geographically close to the broker's trading servers to minimise the round-trip latency between the EA's order request and the broker's execution. For latency-sensitive strategies, the distance between the VPS and the broker's server affects execution quality in ways that are measurable in backtesting terms and significant in live trading.
EA configuration for VPS deployment — the input parameters set correctly for live trading, the risk management parameters appropriate for the account size and risk appetite, the broker-specific parameters configured for the live broker. The pre-live checklist that confirms the EA is correctly configured before real money is committed.
Monitoring the EA in live operation — the MetaTrader journal and expert log review, the position and P&L monitoring that confirms the EA is operating as expected, and the alert configuration that notifies the trader of events requiring attention.
Integration With Broader Trading Infrastructure
Expert Advisors that need to communicate with external systems — receiving signals from an external signal generator, sending trade data to a portfolio management system, reporting to a risk monitoring platform — are integrated through the mechanisms that MetaTrader supports for external communication.
DLL integration. For EAs that need to call external libraries — connectivity to external databases, real-time data feeds, or proprietary calculation engines — DLL integration provides the bridge between the EA's MQL code and external C++ or C# libraries.
Named pipe and socket communication. For EAs communicating in real time with external systems — receiving signals from a Python strategy engine, sending trade events to a monitoring platform — socket-based communication through MQL's socket functions provides the real-time data channel.
File-based integration. For simpler external integrations — reading a signal file that an external system writes, writing a trade log that an external system reads — file-based communication through MQL's file functions provides a robust integration mechanism that does not depend on real-time connectivity.
Technologies Used
- MQL4 — MetaTrader 4 Expert Advisor development
- MQL5 — MetaTrader 5 Expert Advisor development
- C++ / C# — DLL development for EA external integrations
- Python — signal generation and external strategy engine connectivity
- Rust — high-performance external calculation engines connected to MQL via socket or DLL
- MetaTrader Strategy Tester — backtesting and optimisation
- VPS infrastructure — Windows VPS deployment for always-on EA operation
- SQL (SQLite / MySQL) — trade logging and performance data storage for EAs with external database integration
- REST / WebSocket — external signal reception and data provider connectivity
Expert Advisors That Hold Up in Live Trading
The difference between an Expert Advisor that performs well in backtesting and one that performs well in live trading is primarily the quality of its order management, its error handling, and its robustness to the conditions that live trading produces but backtesting does not. Partial fills, requotes, connectivity interruptions, broker-specific behaviour, and the accumulated edge cases of continuous operation are the conditions that separate Expert Advisors that are production-ready from those that are not.
Building an Expert Advisor to a standard that holds up in live trading requires implementing the order management, the error handling, and the robustness features that the EA's live deployment environment demands — not the simplified version that backtesting validates.
Automate the Strategy, Not the Compromise
The purpose of an Expert Advisor is to execute the strategy as designed — consistently, precisely, and continuously. An EA that executes a simplified version of the strategy, or that requires manual intervention for the cases it cannot handle, is not automation. It is partial automation with manual exception handling. Full automation requires an EA built to handle the full scope of what the strategy and the market can produce.