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.
Benefits of Automating Trading on MT4 and MT5
Automated trading offers several advantages over manual trading, including:
- Speed and Efficiency: Algorithms can execute trades instantly without human intervention, reducing delays and errors.
- Elimination of Emotions: Fear and greed often impact decision-making in manual trading. Automation ensures discipline and adherence to strategy.
- 24/7 Trading: With automation and a VPS (Virtual Private Server), trading can continue around the clock, even when the trader is offline.
- Backtesting and Strategy Optimisation: Automated strategies can be tested against historical data to refine their effectiveness before being deployed in live trading.
- Multi-Asset Trading: EAs can scan and trade multiple instruments simultaneously, which would be difficult for a human trader to manage manually.
Key Differences Between MT4 and MT5 in Algorithmic Trading
Although both platforms allow automated trading, there are some key differences between them:

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.
Understanding Expert Advisors (EAs) and Scripts
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.
What Are Expert Advisors (EAs)?
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
- Fully Automated Trading: EAs can open, modify, and close trades without manual input.
- Strategy Implementation: They follow predefined trading rules and indicators to identify trading opportunities.
- Risk Management: EAs can include stop-loss, take-profit, and trailing stop mechanisms.
- 24/7 Operation: EAs can trade continuously without requiring the trader to be online.
Types of Expert Advisors:
- Trend-Following EAs – Identify and trade in the direction of the prevailing trend.
- Scalping EAs – Execute multiple small trades to profit from minor price movements.
- Grid EAs – Use a grid trading strategy to place buy and sell orders at predefined price levels.
- Hedging EAs – Open multiple positions to reduce risk exposure.
- News Trading EAs – Monitor economic news events and trade based on market volatility.
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).
Difference Between Expert Advisors and Scripts
While both EAs and Scripts are used for automation in MetaTrader, they serve different purposes.

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.
Setting Up Automated Trading on MT4 and MT5
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.
Step 1. Enabling Automated Trading
Before running EAs, you must enable automated trading in the platform settings.
- Enable Automated Trading in MT4/MT5
- Click Tools > Options (or press Ctrl+O).
- Navigate to the Expert Advisors tab.
- Check the box "Allow automated trading".
- Ensure the following options are unchecked to prevent interruptions:
- "Disable automated trading when the account is changed."
- "Disable automated trading when the profile has been changed."
- "Disable automated trading when the chart symbol or period is changed."
- Enable Automated Trading on the Toolbar
- Locate the AutoTrading button at the top of the platform.
- Click the button to turn it green, indicating automated trading is enabled.
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.
- Download or Create an EA
- Download an EA from the MetaTrader Market, a third-party provider, or your broker.
- If you develop your own EA, ensure it is coded in MQL4 (for MT4) or MQL5 (for MT5).
- Install the EA in the Correct Folder
- Open MetaTrader and click File > Open Data Folder.
- Navigate to MQL4/Experts (for MT4) or MQL5/Experts (for MT5).
- Copy the EA file (.ex4 for MT4, .ex5 for MT5) into the Experts folder.
- Refresh or Restart MetaTrader
- In the Navigator window, right-click Expert Advisors and select Refresh.
- Alternatively, restart MetaTrader to load the new EA.
- Attach the EA to a Chart
- Open the chart showing the asset you want to trade.
- Drag and drop the EA from the Navigator window onto the chart.
- A settings window will appear.
- Configure EA Settings
- In the EA settings window, go to the Common tab.
- Check "Allow live trading".
- Adjust inputs (parameters) in the Inputs tab (e.g., lot size, stop-loss, take-profit).
- Confirm EA is Running
- The top-right corner of the chart should show a smiley face (MT4) or a green icon (MT5).
- Automated trading is not enabled if it shows a sad face (MT4) or a red icon (MT5).
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 Optimization
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.
What is Backtesting?
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.
How Backtesting Works in MT4/MT5
- Open the Strategy Tester:
- In MetaTrader, go to View > Strategy Tester or press Ctrl+R.
- Select the EA to Test:
- In the Strategy Tester window, choose your EA from the Expert Advisor dropdown.
- Choose a Symbol and Timeframe:
- Select a currency pair (e.g., EUR/USD) or asset.
- Pick a timeframe (e.g., M1, H1, D1) depending on the strategy.
- Select Model for Backtesting:
- Every tick (most accurate but slowest)
- 1-minute OHLC (faster but less precise for scalping)
- Open prices only (fastest but least accurate)
- Set the Period and Execution Delay:
- Define the historical data range.
- Adjust execution delays to simulate real trading conditions.
- Enable "Visual Mode" (Optional):
- If you want to see how trades are executed on the chart, enable Visual Mode and adjust the speed.
- Start the Test and Analyze Results:
- Click Start and wait for the test to complete.
- Review the results in the Results, Graph, and Report tabs.
Backtesting options in MT5 (EN)
Backtesting options in MT5 (SC)
Backtesting options in MT5 (TC)
Analysing Backtest Results
It is crucial to analyse the results of backtesting. Once the backtest is complete, traders must evaluate the following key metrics:

Optimisation: Improving EA Performance
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.
How to Optimize an EA in MetaTrader:
- Open the Strategy Tester and Enable Optimization:
- Select your EA and asset as in backtesting.
- Check the box for Optimization Mode.
- Set Input Parameters for Optimization:
- Define the range and step values for each parameter (e.g., testing SMA period 10–50 in steps of 5).
- Common parameters to optimise:
- Moving Average periods
- RSI levels (e.g., overbought at 70, oversold at 30)
- Stop-loss and take-profit levels
- Lot size and risk management settings
- Choose the Optimization Method:
- Slow Optimization: Tests all combinations (accurate but time-consuming).
- Genetic Algorithm (Fast Optimization): Uses AI to test the best combinations efficiently.
- Run the Optimization and Review Results:
- Click Start to begin the optimisation process.
- After completion, check the Optimization Results tab for the best settings.
- Select the Best Settings and Retest:
- Choose the parameters with the best profit-to-risk ratio.
- Perform another backtest using these optimised settings.
Backtesting optimisation option in MT5 (EN)
Backtesting optimisation option in MT5 (SC)
Backtesting optimisation option in MT5 (TC)
Walk-Forward Testing (Out-of-Sample Testing)
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.
Steps for Walk-Forward Testing:
- Split Historical Data into Two Parts: Use 70% for backtesting and optimisation (in-sample data); use 30% for forward testing (out-of-sample data).
- Apply the Optimized Parameters to the Out-of-Sample Data: Run the EA on fresh historical data not used in optimisation; check if the performance remains consistent.
- Compare the Results: If the EA performs well in walk-forward testing, it is likely robust; if the EA fails, the strategy may be curve-fitted and need adjustments.
Live Testing on a Demo Account
Before deploying an EA on a real account, run it in demo mode to see how it behaves under real market conditions.
Things to Monitor in Live Testing:
- Execution Speed: Is there a delay in order execution?
- Slippage: How much does the price move before the trade is placed?
- Spread Sensitivity: Does the EA perform worse in high-spread conditions?
- Performance Stability: Are backtest and real-time results consistent?
Running and Monitoring an EA
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:
- Execution speed: Check if trades are executed with minimal delay
- Trade frequency: Ensure the EA follows its expected trading pattern
- Win/Loss ratio: Track performance consistency over time
- Drawdown: Monitor the maximum percentage decline in account balance
- Slippage: Compare expected vs. actual execution prices
- Profit/Loss: Assess overall profitability and risk-adjusted returns
VPS for 24/7 Trading
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:
- 24/7 Trading Uptime: Ensures your EA runs non-stop, even if your local device is turned off.
- Faster Order Execution: Reduces latency by hosting your trading platform near broker servers.
- Lower Risk of Downtime: Protects against internet outages, power failures, or system crashes.
- Enhanced Security: VPS providers offer secure environments with firewall protection.
- Multi-Device Access: Traders can monitor and control the VPS from any device, anywhere.
A VPS is crucial for traders running scalping, high-frequency, or news-based strategies, where milliseconds matter.
Trade with Ultima Markets
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.
风险提示:以上内容仅代表作者或嘉宾的观点,不代表 FOLLOWME 的任何观点及立场,且不代表 FOLLOWME 同意其说法或描述,也不构成任何投资建议。对于访问者根据 FOLLOWME 社区提供的信息所做出的一切行为,除非另有明确的书面承诺文件,否则本社区不承担任何形式的责任。
FOLLOWME 交易社区网址: followme.asia
加载失败()