Education Hub

Expert Advisors (EAs) on MetaTrader 5

Expert Advisors are programs that automate your trading on MT5. They follow your rules, execute without emotion, and can run 24 hours a day. This guide covers how they work, how to get them, how to test them, and what risks to watch for.

Reading time: approximately 10 minutes

What Are Expert Advisors?

An Expert Advisor (EA) is a program written in MQL5 that runs inside MetaTrader 5. It monitors the market, applies your trading logic, and places trades automatically based on the rules you define.

Think of an EA as a set of instructions: "If the 50-period moving average crosses above the 200-period moving average on the H1 chart, buy 0.10 lots of EUR/USD with a 30-pip stop loss and a 60-pip take profit." The EA watches for that condition and executes the trade the moment it occurs, whether you are at your desk or asleep.

EAs can range from simple single-rule systems to complex multi-indicator strategies that manage multiple positions across different currency pairs simultaneously. They are not limited to entry signals. They can also manage open trades by trailing stop losses, scaling in or out of positions, and closing trades based on time or profit targets.

Tip: Start simple. Your first EA should automate a basic strategy you already trade manually. Once you see how it behaves across different market conditions, you can add complexity gradually.

How EAs Work

When you attach an EA to a chart in MT5, it runs on every new tick (price update). On each tick, the EA evaluates its conditions and decides whether to open, modify, or close trades.

They follow rules, not emotions

An EA does not panic after a losing streak. It does not hold a losing trade hoping it will recover. It does not double down out of frustration. It executes exactly what it is programmed to do, every time. For many traders, removing emotion from execution is the biggest advantage of automation.

They trade around the clock

The forex market runs 24 hours a day, five days a week. No human can monitor it constantly. An EA can. If your strategy triggers a signal at 3:00 AM while you are sleeping, the EA takes the trade. You do not miss opportunities because you were not at your screen.

They execute instantly

Humans need time to spot a setup, calculate position size, and click buttons. An EA does all of this in milliseconds. For strategies where timing matters (breakout trades, news spikes), faster execution can mean better fill prices.

Building vs Buying EAs

You have three main options for getting an EA:

Build your own

If you know MQL5 (or want to learn), you can code an EA yourself. MT5 includes the MetaEditor IDE with syntax highlighting, debugging tools, and documentation. Building your own gives you complete control over the logic and lets you implement strategies that are uniquely yours.

The learning curve for MQL5 is moderate. If you have any programming experience (Python, JavaScript, C++), you can pick up the basics in a few weeks. The official MQL5 documentation and community forums are extensive.

Buy from the MQL5 marketplace

The MQL5 marketplace is the official store for MetaTrader add-ons. Thousands of EAs are available, both free and paid. Prices range from free to several thousand dollars. Each listing includes a description, screenshots, user reviews, and often a demo version you can test before buying.

Be cautious with marketplace EAs. Read reviews carefully. Check how long the EA has been listed and whether the developer is responsive to questions. A backtest result alone does not guarantee future performance. Always test on demo first.

Hire a developer

The MQL5 freelance section connects you with professional developers who can build a custom EA to your specifications. You describe the strategy, they write the code. Costs vary depending on complexity, typically ranging from $100 to $2,000+. This option makes sense if you have a specific strategy that you trade manually and want to automate, but do not want to learn programming.

Backtesting Your EA

Before running any EA on a live account, you need to test it against historical data. MT5's Strategy Tester is built for this.

How to backtest in MT5

1

Open the Strategy Tester (Ctrl+R or View menu). Select your EA from the dropdown.

2

Choose the symbol (currency pair), timeframe, and date range. Use at least 2 to 3 years of data to get meaningful results. Select "Every tick based on real ticks" for the most accurate simulation.

3

Set your initial deposit and leverage to match your real account conditions. Configure the EA's input parameters.

4

Run the test. MT5's multi-threaded tester uses all your CPU cores, so results come fast. Review the equity curve, drawdown, win rate, profit factor, and total trades.

What to look for in results

Profit factor

Gross profit divided by gross loss. Anything above 1.0 means the EA is profitable overall. Most viable EAs have a profit factor between 1.3 and 2.5. Above 3.0 over a long period usually indicates curve-fitting.

Maximum drawdown

The largest peak-to-trough decline in account equity. A 30% drawdown means at some point, the account dropped 30% from its high. Can you handle that psychologically? If not, the EA's risk settings need adjustment.

Number of trades

A backtest with only 50 trades is not statistically reliable. You need hundreds of trades to draw meaningful conclusions. More data points mean more confidence in the results.

Important: Good backtest results do not guarantee future performance. Markets change. An EA optimized perfectly for 2023 data might fail in 2026 conditions. Always run a forward test on demo for at least 1 to 3 months before going live.

Running EAs on LHFX

LHFX allows Expert Advisors on all account types with no restrictions. There are no limits on trading frequency, strategy type, or holding time.

No restrictions on EA types

Scalping EAs, grid EAs, martingale EAs, trend-following EAs, news trading bots. All are permitted. You choose your strategy. LHFX does not interfere with how you trade.

STP/ECN execution

Your EA's orders go directly to the market. No dealing desk. No requotes on market orders. This matters for high-frequency EAs where execution speed and fill quality directly affect performance.

Low latency

Fast execution matters for EAs. If you are running a latency-sensitive strategy, consider using a VPS located near the trading server for the best possible order execution times.

Get started with MT5 on LHFX: MetaTrader 5 platform | Account types

Risks of Automated Trading

EAs are powerful tools, but they are not magic money machines. Here are the risks you need to understand:

Overfitting (curve-fitting)

The most common trap. An EA is optimized to perfection on historical data, producing beautiful backtest results. But it was tuned so specifically to past conditions that it fails when the market behaves even slightly differently. This is why forward testing on demo is essential before going live.

Market regime changes

Markets go through phases: trending, ranging, volatile, quiet. An EA designed for trending markets will lose money during prolonged ranges, and vice versa. No single EA works well in all conditions. You need to understand what environment your EA is designed for and monitor whether conditions have changed.

Technical failures

Internet outages, power failures, platform crashes, and VPS downtime can all interrupt your EA. Positions may be left unmanaged. Always have stop losses set at the broker level (not just in the EA's code) so that if the EA disconnects, your risk is still capped.

Monitoring is still required

Automated does not mean unattended. Check your EA's performance daily. Review weekly results. Watch for unusual behavior like trades not executing, abnormal drawdowns, or the EA opening positions it should not. Automation handles execution, but you still own the strategy and the risk.

Risk disclosure: CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. Automated trading does not eliminate risk. Past backtest performance does not guarantee future results. Only trade with capital you can afford to lose.

Frequently Asked Questions

Run Your EAs on LHFX

No restrictions on Expert Advisors. STP/ECN execution, raw spreads, and MetaTrader 5. Open an account and start automating.