Systems and executionIntroductory12 min read

MetaTrader Expert Advisors: What They Are and How to Use Them

What MetaTrader Expert Advisors are, how MT4 and MT5 differ, how to install and backtest one, and why rules and source code matter more than a promise.

Trader configuring an Expert Advisor at a computer

An Expert Advisor (EA) is a program that runs inside MetaTrader and trades by rules you can write down: when to enter, where to exit, how much to risk. The program is the easy part. What decides whether an EA is useful to you is whether you can read its rules, see its code, test it on data you control and change it to fit your account. That is the standard we build around at TradeAndRoll: every robot in our collections comes with its trading rules, source code and AI prompt ideas, so you can examine the strategy instead of trusting a label.

This guide covers what an EA is, how MT4 and MT5 differ, how to install and enable one, how to backtest it, and how to adapt it. TradeAndRoll provides Python source systems: using their rules inside MT4 or MT5 requires a separate implementation or integration and testing. The EA installation steps below apply to compatible MetaTrader files, not directly to the Python demo.

TL;DR

  • An Expert Advisor is a program that attaches to one chart in MetaTrader 4 or 5 and can open, modify and close orders by fixed rules.
  • MT4 EAs (MQL4) and MT5 EAs (MQL5) are not interchangeable, so check the platform before you pick a robot.
  • Installing is a file copy plus one toggle, but the real work is testing: model quality, costs, deposit and leverage settings decide whether a backtest means anything.
  • Readable rules and source code let you check what a robot does and adapt it. Promises of guaranteed or very high returns are a fraud warning sign, according to US regulators.
  • Our free demo lets you inspect sample materials before you consider a collection.

What an Expert Advisor actually is

In MetaTrader, an EA is an automated trading program. It can open, modify and close orders, and only one EA can be attached to a given chart at a time. An indicator is different: it only draws analysis data on a chart, and you can stack several on the same chart. Both are described in Andrew Young’s book on EA programming for MetaTrader 5.

So an indicator shows you something, and an EA does something. A moving-average indicator plots two lines. A moving-average EA buys when the fast line crosses above the slow one, places a stop, and closes the trade on its exit rule.

Indicator plots lines while EA executes trades

An EA only works while the platform is running. MQL5 EAs place and manage trades as long as MT5 is open on a computer with a working internet connection. If the machine sleeps or the connection drops, the EA stops acting. Many traders run EAs on a always-on computer for that reason, and test what happens when the connection breaks (more on that below).

MT4 or MT5: pick the platform first

Both platforms support EAs, but they use different languages: MT4 uses MQL4 and MT5 uses MQL5. An EA written for one may need modification to run on the other. In practice that is stricter than it sounds: MQL4 is not compatible with MQL5, and .mq4 and .ex4 files will not work on MT5.

The platforms differ in ways that matter for testing:

Feature MT4 MT5
Language MQL4 MQL5
Chart timeframes 9 21
Built-in indicators 30 38
Pending order types 4 6
Strategy Tester Single-threaded Multi-threaded, multi-currency

The figures come from a broker’s MT4 vs MT5 comparison. The tester difference is the one you will feel: MT5 can test across several currencies and use multiple processor cores, which shortens parameter studies.

One MT5 limit to know before you automate: EAs cannot trade Share CFDs on MT5 and such orders are rejected at that broker. Check which instruments your own account allows EAs to trade.

Because a strategy is more portable than a file, rules written in plain language matter. If you hold the rules, you can understand the logic regardless of which platform you run. Our guide to Forex trading systems walks through how rules are written, tested and adapted.

Installing and enabling an EA, step by step

The steps below follow the MT5 user guide from OANDA. MT4 is similar, with MQL4 folders instead.

  1. Open the data folder. In MT5, go to File > Open Data Folder > MQL5 > Experts.
  2. Add the EA file. Paste or drag it into the Advisors folder, then restart MT5.
  3. Find it in Navigator. The EA appears under Expert Advisors.
  4. Attach it to a chart. Double-click it or drag it onto the chart you want it to trade. Use the symbol and timeframe the rules were written for.
  5. Allow automated trading. On the Common tab, check “Allow Algo Trading”.
  6. Set the inputs. On the Inputs tab, change risk, stop and other settings, then click OK.
  7. Start it. Press the Algo Trading button on the toolbar. A green arrow indicates the EA is active.

Where this goes wrong is almost never the clicking. It is the inputs. An EA with a default lot size that was tuned on a large demo balance can risk far more of a small account than you intended. Read what each input does before you press the button. With rules and code in hand, you can see exactly what each input changes. That is why each robot in our collections ships with trading rules next to the source code: the input names stop being guesses.

Backtesting an EA before it touches real money

A backtest runs the EA over historical prices in the platform’s Strategy Tester. It tells you how the rules would have behaved in the past, with the assumptions you gave it. It does not predict the future, but a careful one exposes bad logic fast. A sound routine looks like this.

1. Choose the modeling method

The tester can approximate price movement or replay it more finely. Testers that use every tick, ideally on real tick data, are generally treated as the most faithful for EAs that react to short moves, as this MT5 backtesting guide explains. A strategy that trades on bar closes can tolerate a coarser model, but one that uses tight stops cannot.

2. Match deposit, leverage and currency to your account

Set the starting balance, leverage and account currency to what you will actually use. A test on a large balance with generous leverage can hide a drawdown that would wipe out a smaller account. If your account currency differs from the pair’s quote currency, profit conversion also changes results, which we cover in how Forex profits convert into your account currency.

3. Include realistic costs

Spread, commission and slippage can turn a profitable-looking backtest into a loser, especially for strategies that trade often. Read our explanation of bid, ask and spread to see where those costs come from and why a fixed test spread can flatter a robot.

4. Split the data

Optimize on one period and check on a different one the EA has not seen. If results fall apart outside the optimization window, the parameters were fitted to noise. Keep the number of tuned inputs small.

5. Read more than net profit

Look at maximum drawdown, the number of trades, the average loss against the average win and how long the worst losing streak lasted. A handful of trades proves little. Ask whether you could sit through the worst stretch without switching the robot off.

6. Stress the unpleasant cases

Test around scheduled news releases, where spreads widen and fills slip: our piece on Forex robots and scheduled news covers clocks, orders and replay. Also test what the robot does when it must stop: how to test a trading robot’s kill switch shows a repeatable way to check it.

7. Run it on a demo account

Forward-test on a demo account for long enough to see it handle several market conditions. Compare the demo trades with what the backtest would have done on the same days. Differences point to cost, timing or data assumptions to fix.

What we do at this stage: every robot comes with its trading rules and source code, so when the backtest and the forward test disagree, you can trace the difference to a specific rule rather than guessing. The free demo also includes market data in CSV files, which gives you material to work with while you learn the process. Our article on moving from a robot demo to a research decision lays out how to structure that review.

How an EA executes rules, and what changes its results

An EA is a loop. On each new tick or bar it reads prices and indicator values, checks its conditions, and sends, modifies or closes orders. Four things most often change the outcome without the logic changing at all:

  • Spreads and execution. Wider spreads at rollover or news raise the cost of every trade and can trigger stops the backtest never saw.
  • Broker settings. Symbol suffixes, minimum lot sizes, stop-level limits and server time zones differ between brokers. An EA built around a particular server clock will misplace its trading hours on another.
  • Inputs. Lot size, stop distance and filters change the risk profile more than most traders expect.
  • Market regime. A trend-following EA tends to struggle in ranges, and a mean-reversion EA tends to struggle when a trend runs hard. Knowing which regime a rule set was designed for tells you when a losing run is normal and when something is broken.

This is the case for rules you can read. If you know that a robot enters on a breakout and exits on a time stop, a flat month in a quiet market is information, not a mystery.

Adapting an EA to your own trading

Most traders do not run an EA unchanged. They adjust session hours, risk per trade, the symbols traded or the filters. There are two routes inside MetaTrader.

The first is editing source code in MetaEditor, the code editor that ships with the platform. The second is the MQL5 Wizard, which lets you build an EA from standard modules. It offers an “Expert Advisor (template)” option for scaffolding and an “Expert Advisor (generate)” option for no-code creation using the standard library. The MetaEditor help page on generating a ready-made EA describes how the Wizard assembles one from trading signal modules.

The Wizard is a quick way to get a working skeleton. A robot that arrives with its rules and source code gives you something more concrete: a documented strategy to modify one change at a time, retesting after each. Change one thing, rerun the test, keep a log. If you change five inputs at once, you will not know which one helped.

This is where AI tools come in. Large language models can explain a block of code, suggest a rewording of a rule, or draft a test checklist. Every robot in our collections includes AI prompt ideas for this kind of work, and our guide to AI trading prompts for Forex shows templates and how to tie them to explicit rules. Treat the output as a draft you verify by running a test, not as an answer. If you are curious how machine learning approaches the problem differently, reward design for reinforcement learning trading explains what a learning system is actually told to optimize.

Risk and marketing claims you should know

Leveraged Forex trading can lose money quickly, and automation does not remove that. No EA, AI-assisted or not, can promise a result. The US Commodity Futures Trading Commission warns that fraudsters tout automated trading algorithms with unreasonably high or guaranteed returns, and that AI cannot predict sudden market changes. Use that as a screen for any marketing you read: a robot described only by a profit curve and a promise is not described at all.

Read our trading risk disclosure before you trade any system with real funds, and only risk money you can afford to lose. If you are unsure whether leveraged trading suits your finances, speak with a licensed financial adviser.

Where TradeAndRoll fits

Where TradeAndRoll fits

Our approach is built for the trader who wants to see inside the system. Each robot comes with its trading rules, its source code and AI prompt ideas. That lets you examine how the strategy works and how it is implemented, then adapt it.

To start, the free demo gives you sample materials, including market data in CSV files, with 10 Forex robots to inspect before you discuss a purchase. When you want more, the 30 additional Forex robots are a one-time purchase at €270 plus applicable taxes. If you want a steady supply, an optional subscription adds 20 additional Forex robots each month for €99 per month plus applicable taxes.

The systems are delivered with Python source code, rules and research prompts. Market-data CSV files are included only in the demo; purchases are arranged by email at info@tradeandroll.com.

Tradeandroll

Browse the full range of Forex trading robots with source code and open the demo to see how the rules and code are laid out.

A practical starting checklist

  1. Confirm your platform (MT4 or MT5) and that your account allows EAs on the instruments you want.
  2. Read the rules and code of a robot before attaching it to a chart.
  3. Backtest with every-tick modeling, your real deposit and leverage, and realistic costs.
  4. Validate on data the optimization never saw.
  5. Forward-test on a demo account, then size down for the first live period.
  6. Test the stop condition and the kill switch.
  7. Change one input at a time and keep a log.

FAQ

What is an Expert Advisor in MetaTrader?

It is an automated trading program that attaches to a chart and can open, modify and close orders by coded rules. Only one EA can run on a chart at a time, and it works only while the platform is running with an internet connection. An indicator, by contrast, only displays analysis on the chart.

Can I use an MT4 Expert Advisor on MT5?

Not directly. MT4 EAs are written in MQL4 and MT5 EAs in MQL5, and the compiled files are not compatible. The strategy has to be recoded for the other platform, which is easier when you have the written rules and the source code.

How do I turn on an Expert Advisor?

Copy the EA file into the Experts folder through File > Open Data Folder, restart the platform, and drag the EA from Navigator onto a chart. Check “Allow Algo Trading” on the Common tab, set the inputs, click OK and press the Algo Trading toolbar button. A green arrow shows it is active.

Do I need to know how to code to use an EA?

Not to run one, but reading the code helps you understand and adapt it. The MQL5 Wizard can generate a basic EA from standard modules without coding. With a robot whose rules are written out alongside its source code, you can follow what each section does and change it step by step.

How should I test an EA before going live?

Backtest with fine-grained modeling, your own deposit, leverage and costs, then check the results on unseen data and run a demo forward test. Review drawdown and trade count, not only profit. Start live trading with reduced size.

Sources

Back to the Blog