Automated trading, or algorithmic trading, involves using pre-programmed instructions to execute trades automatically based on specific market conditions. Instead of manually placing buy or sell orders, traders use algorithms to scan the market, analyse data, and execute trades within milliseconds.
MetaTrader 4 (MT4) and MetaTrader 5 (MT5) are two of the most widely used trading platforms that support automation through Expert Advisors (EAs) and scripts. By leveraging automation, traders can remove emotions from decision-making, ensure consistent execution of strategies, and take advantage of market opportunities 24/7.
Automated trading offers several advantages over manual trading, including:
Although both platforms allow automated trading, there are some key differences between them:
Feature | MT4 | MT5 |
Programming Language | MQL4 | MQL5 (more advanced) |
Multi-Asset Trading | Primarily for forex | Supports forex, stocks, commodities, and futures |
Order Execution Types | 3 types | 4 types |
Backtesting | Single-threaded | Multi-threaded (faster and more efficient) |
Economic Calendar Integration | Not available | Built-in economic calendar |
Depth of Market (DOM) | Limited | Advanced DOM for better order management |
MT4 remains the preferred choice for forex traders due to its simplicity and widespread adoption. At the same time, MT5 is better suited for traders who need advanced order types, faster backtesting, and multi-asset trading capabilities.
MetaTrader 4 (MT4) and MetaTrader 5 (MT5) offer powerful automation capabilities through Expert Advisors (EAs) and Scripts. These tools allow traders to execute trading strategies without manual intervention, making trading more efficient and systematic.
Understanding the differences between EAs and Scripts is crucial for choosing the proper automation method.
Expert Advisors (EAs) are automated trading programs that run on the MetaTrader platform. They are coded using MQL4 (for MT4) or MQL5 (for MT5) and can analyse price data, execute trades, and manage positions based on pre-set rules.
Features of EAs
EAs continuously monitor the market, analyse price movements, and execute trades based on pre-set conditions. They can be used for fully automated and semi-automated trading (where traders manually confirm trade signals).
While both EAs and Scripts are used for automation in MetaTrader, they serve different purposes.
Feature | Expert Advisors (EAs) | Scripts |
Purpose | Automates the entire trading process | Executes a one-time action |
Execution | Runs continuously and reacts to market changes | Executes once and stops |
Use Case | Trading strategies, risk management, position monitoring | Placing orders, closing positions, modifying settings |
For example, traders can use EAs to execute trades based on moving average crossovers, but they can also use a script to close all open trades instantly.
Automating trading in MetaTrader 4 (MT4) and MetaTrader 5 (MT5) involves installing the platform, enabling automated trading, adding Expert Advisors (EAs), and configuring settings. This section provides a step-by-step guide to setting up automated trading.
Let’s assume you already use MetaTrader 4 (MT4) or MetaTrader 5 (MT5). You can also check our guide in the Introduction.
Before running EAs, you must enable automated trading in the platform settings.
A screenshot of options to enable automated trading in MT5 (EN)
A screenshot of options to enable automated trading in MT5 (SC)
A screenshot of options to enable automated trading in MT5 (TC)
Step 2. Adding an Expert Advisor (EA) to MT4/MT5
Once automated trading is enabled, you need to install an EA.
Adding an EA from the Navigator window in MT5 (EN)
Adding an EA from the Navigator window in MT5 (SC)
Adding an EA from the Navigator window in MT5 (TC)
Finally, backtest and run the EA on a demo account for at least a few weeks to confirm stability. Also, ensure the trading strategy aligns with market conditions (trend, volatility, etc.). And use proper risk management settings to avoid excessive drawdowns.
Backtesting and optimisation are essential steps in automated trading. They help traders evaluate the performance of their Expert Advisors (EAs) before deploying them in a live market. By testing historical data and refining strategies, traders can identify potential weaknesses and fine-tune parameters for maximum profitability.
Backtesting is the process of running an EA against historical price data to assess how it would have performed in the past. It helps traders identify a trading strategy’s effectiveness, measure risk and reward ratios, detect weaknesses and areas for improvement, and gain confidence before using the EA in a live market.
Backtesting options in MT5 (EN)
Backtesting options in MT5 (SC)
Backtesting options in MT5 (TC)
It is crucial to analyse the results of backtesting. Once the backtest is complete, traders must evaluate the following key metrics:
Metric | Description |
Net Profit | Total profit/loss over the test period. |
Win Rate (%) | Percentage of winning trades vs. total trades. |
Drawdown (%) | Largest peak-to-trough decline in equity. |
Profit Factor | Gross profit divided by gross loss (higher is better). |
Sharpe Ratio | Measures risk-adjusted return (higher is better). |
Maximum Consecutive Losses | Helps evaluate the strategy’s risk tolerance. |
Optimisation involves adjusting input parameters (e.g., stop-loss, take-profit, indicator settings) to improve an EA’s performance. It helps find the best settings for different market conditions.
Backtesting optimisation option in MT5 (EN)
Backtesting optimisation option in MT5 (SC)
Backtesting optimisation option in MT5 (TC)
Backtests may be overfitted to historical data, meaning the EA may not perform well in real-time trading. Walk-forward testing prevents this by testing optimised parameters on new, unseen data to verify robustness.
Before deploying an EA on a real account, run it in demo mode to see how it behaves under real market conditions.
Once an Expert Advisor (EA) has been developed, backtested, and optimised, it’s time to deploy it in a live trading environment. However, launching an EA is just the beginning—continuous monitoring and management are essential to ensure smooth operation and long-term profitability. This section covers the steps to deploy an EA, best practices for monitoring, and how to troubleshoot potential issues.
Key things to consider when monitoring an EA’s performance:
A Virtual Private Server (VPS) is a remote server that runs continuously, allowing traders to operate their Expert Advisors (EAs) without interruptions. Since automated trading requires stable internet, minimal latency, and an uninterrupted power supply, using a VPS ensures that trading bots function efficiently even when your local computer is off.
Key benefits of using a VPS:
A VPS is crucial for traders running scalping, high-frequency, or news-based strategies, where milliseconds matter.
Ultima Markets is a fully licensed broker and a multi-asset trading platform offering access to
250+ CFD financial instruments, including Forex, Commodities, Indices and Shares. We
guarantee tight spreads and fast execution. Until now, we have served clients from 172
countries and regions with our trustworthy services and well-built trading systems.
Ultima Markets has achieved remarkable recognition in 2024, winning prestigious awards
such as the Best Affiliates Brokerage, Best Fund Safety in Global Forex Awards, and
the Best APAC CFD broker in Traders Fair 2024 Hong Kong. As the first CFD broker to join
the United Nations Global Compact, Ultima Markets underscores its commitment to
sustainability and the mission to advance ethical financial services and contribute to a
sustainable future.
Ultima Markets is a member of The Financial Commission, an international independent
body responsible for resolving disputes in the Forex and CFD markets.
All clients of Ultima Markets are protected under insurance coverage provided by Willis
Towers Watson (WTW), a global insurance brokerage established in 1828, with claims
eligibility up to US$1,000,000 per account.
Open an account with Ultima Markets to start your index CFDs trading journey.