CFDs and forex are complex instruments and come with a high risk of losing money rapidly due to leverage. Risk disclosure

Expert Advisors in MetaTrader 5 and MetaTrader 4

This guide explains what a forex EA does, how to install and run one in MT5 or MT4, and why you should test it and doubt any profit claims before using it.

Extrade Pakistan editorial team ·

On this page
  1. What an Expert Advisor is
  2. How to install an EA in MT5
  3. How to install an EA in MT4
  4. Enable algo trading
  5. Inputs: the settings that matter
  6. Why "profitable EAs" for sale are a red flag
  7. Test before any live use
  8. Frequent questions

What an Expert Advisor is

An Expert Advisor (EA) is a program that runs inside MetaTrader and can open, change and close trades for you. People also call it a forex robot or a trading bot. EAs for MetaTrader 5 are written in MQL5 and EAs for MetaTrader 4 in MQL4. For more on these languages, see MQL4 and MQL5.

An EA follows fixed rules written by its programmer, such as "buy when one moving average crosses above another, with a set stop loss." It cannot judge news, unusual volatility or a sudden gap. It does exactly what its code says, and that includes any mistakes in the code.

MetaTrader has three related kinds of program:

Program What it does Can it trade?
Expert Advisor Runs on a chart and reacts to each new price Yes
Indicator Draws lines or values on a chart No
Script Runs once when you start it, then stops Yes, one action

An EA works only while your terminal is open and connected. If you close MetaTrader or your PC goes to sleep, the EA stops. Open positions stay open but are no longer managed by the EA.

Past data (tuned)New datastart
Over-fitting: a strategy tuned to past data looks smooth on that data and often fails on data it has not seen. Test on a separate period and on a demo first. Illustrative example: made-up numbers for learning, not real prices or a broker's conditions.

How to install an EA in MT5

  1. Open MetaTrader 5 and choose File → Open Data Folder.
  2. Open the MQL5 folder, then Experts.
  3. Copy the EA file into the Experts folder. A compiled file runs as it is. A source file needs compiling in MetaEditor first.
  4. Go back to the terminal. In the Navigator window (Ctrl+N), right-click Expert Advisors and choose Refresh.
  5. The EA now appears in the list.

You can also get EAs from the Market tab in the Toolbox, which links to the official MQL5 Market. EAs from there install themselves into the correct folder.

Only use files from a source you trust. An EA can place trades on your account, and a file that allows DLL imports can run code outside MetaTrader.

How to install an EA in MT4

The steps are almost the same:

  1. Choose File → Open Data Folder.
  2. Open MQL4, then Experts, and paste the file.
  3. Refresh the Navigator or restart the terminal.

An MT4 EA does not run in MT5 and an MT5 EA does not run in MT4. The two languages differ, so a file has to be written or rewritten for the platform you use. See MT4 vs MT5 for other differences.

Enable algo trading

Installing the EA does not let it trade. You have to switch trading on in two places.

Terminal-wide switch. In MT5, click the Algo Trading button on the toolbar or press Ctrl+E. In MT4 the button is called AutoTrading. When it is off, no EA can trade.

Per-EA permission. Drag the EA from the Navigator onto a chart. In the window that opens, go to the Common tab and tick Allow Algo Trading (in MT4: Allow live trading). Click OK.

The EA's name then appears in the top-right corner of the chart. Its icon shows whether it is allowed to trade.

You can set global rules under Tools → Options → Expert Advisors. Examples are whether DLL imports are allowed and which web addresses an EA may contact. Leave DLL imports off unless you know why the EA needs them.

The Experts and Journal tabs in the Toolbox show messages from the EA and from the terminal. Check them first if nothing happens. Common causes are listed on MetaTrader errors.

Inputs: the settings that matter

The Inputs tab in the EA window lists the parameters its author made adjustable. Typical inputs:

You can save a set of inputs and load it later with Save and Load on the same tab. The chart and its EA are also kept in templates and profiles.

Why "profitable EAs" for sale are a red flag

Many robots are sold through social media, WhatsApp or Telegram with claims of steady monthly profit. Treat these claims with strong suspicion:

The SECP regularly cautions the public against illegal investment and trading platforms promoted through messaging apps. Keep one point in mind: per the SECP, offshore platforms have no Pakistani licence or oversight and offer no legal protection or recourse. Read Law and regulators and Regulation and Safety before you commit money anywhere.

Leveraged forex and CFD trading can lose money fast. An EA can lose it faster, because it trades without pausing.

Test before any live use

  1. Read the logic. Know when the EA enters, exits and adds positions. If the seller will not explain it, that tells you something.
  2. Run the Strategy Tester. Test across different market periods with realistic spreads. Look at drawdown, the largest fall from a peak, not only the final balance. See Strategy tester.
  3. Forward-test on a demo account. Run it in real time on a demo account long enough to see different market conditions.
  4. Check the conditions. Spread, commission and swap (the overnight fee) change results. See Contract specifications and Swap fees.
  5. Plan for interruptions. Decide how the terminal stays online and what happens to open trades if it disconnects.

General principles for position size and losses are on Risk management.

Frequent questions

What is an expert advisor in MT5?

It is an MQL5 program attached to a chart that can open, manage and close trades automatically according to fixed rules.

Why is my EA not trading?

Usually the terminal's Algo Trading button is off, or "Allow Algo Trading" was not ticked when you attached the EA. Check the Experts and Journal tabs for messages.

Can I use an MT4 EA in MT5?

No. It has to be rewritten in MQL5 or replaced with an MT5 version.

Does the EA keep working if I close MetaTrader?

No. It runs only while the terminal is open and connected.

Is a forex robot a safe way to earn income?

No. An EA only automates rules, and those rules can lose money. Leveraged trading carries a high risk of loss, and an EA does not reduce that risk.

Where do I see which trades the EA made?

Its trades carry its magic number and usually its name in the comment. You can review them in Trade history.

Sources

  1. Securities and Exchange Commission of Pakistan (press release, 09.04.2025) · secp.gov.pk › Press Release SECP Cautions Public Against Illegal Offshore Trading an — checked 2026-11-11

Related pages