Trading forex and CFDs on leverage is high risk. Most retail accounts lose money. Read the risk warning

How to Install an Expert Advisor on MT5, Including Market EAs and Error Fixes

To install an expert advisor on MT5, click File, then Open Data Folder, copy the .ex5 (or .mq5) file into MQL5, then Experts, refresh the Navigator, and drag the EA onto a chart of the right symbol. Then make sure the Algo Trading button on the toolbar is on and "Allow Algo Trading" is ticked in the EA's Common tab. EAs bought or downloaded from the built-in MetaTrader Market install themselves, but they still need the same permissions, and MT5 adds a few traps MT4 users do not expect, notably account mode and order filling rules.

Key takeaways

  • MT5 only runs .ex5 files written in MQL5; MT4 .ex4 files will not load.
  • Manual installs go in the MQL5\Experts folder reached via File, Open Data Folder; Market purchases install into MQL5\Experts\Market automatically.
  • Trading needs both the global Algo Trading button and the per-EA "Allow Algo Trading" setting.
  • Check whether your account is netting or hedging; many EAs assume one and misbehave on the other.
  • MT5 error codes such as 10027, 10030 and 10016 point directly to the fix.

MT5 files and folders at a glance

MetaTrader 5 keeps everything you add in a per-installation data folder, separate from the program files. Inside it, the MQL5 folder holds the subfolders MT5 reads at start-up. The EA itself is either a compiled .ex5 file or .mq5 source code that MetaEditor compiles. Vendors often supply extra files alongside it.

File typePurposeGoes in
.ex5 / .mq5Expert advisorMQL5\Experts (subfolders allowed)
.ex5 / .mq5Custom indicator the EA callsMQL5\Indicators
.mqhInclude file for compiling sourceMQL5\Include
.dllExternal libraryMQL5\Libraries
.setSaved input settingsMQL5\Presets (or load from anywhere)
Data files (.csv, .txt)Files the EA reads or writesMQL5\Files

If you were sent an .ex4 file, it is an MT4 program and will not run in MT5 under any settings. The two languages handle orders, positions and indicator values differently, which is explained in our comparison of MQL4 versus MQL5. You need an MT5 version from the developer or a proper port.

Method 1: Manual installation from a file

Open the right folder

In MT5, click File, then Open Data Folder. Explorer opens the data folder for this specific terminal. If you run several MT5 installations, perhaps one per broker or one for a prop firm, each has its own folder, so always open it from the terminal you will trade on.

Copy the files

Open MQL5, then Experts, and paste the EA file. Put any indicators, libraries or include files in their matching folders. Keep the vendor's file names exactly as supplied, because EAs often call indicators by name and a renamed file breaks the link.

Refresh or compile

In the Navigator (Ctrl+N), right-click Expert Advisors and choose Refresh. An .ex5 appears straight away. For an .mq5 file, double-click it to open MetaEditor and press F7 (Compile). Read the Errors tab at the bottom of MetaEditor; zero errors means an .ex5 has been produced next to the source. Warnings are not fatal but are worth reading.

Method 2: Installing from the MetaTrader Market

MT5 includes the MetaQuotes Market, where developers sell or give away EAs. Open the Toolbox (Ctrl+T), go to the Market tab, and search. To buy or rent a paid product you need an MQL5.community account, logged in under Tools, Options, Community. Downloads install automatically into MQL5\Experts\Market and appear in the Navigator.

Purchased Market products are licensed with a limited number of activations, each one tying the product to a computer configuration. Reinstalling Windows or moving to a new VPS can use an activation, so check the remaining count before migrating. Free products and demo versions usually only run in the Strategy Tester or on demo accounts, which is a convenient way to test an EA before paying. Being listed on the Market does not mean an EA is profitable or that MetaQuotes endorses its results; the marketplace checks that products work technically, not that they make money.

Enable algorithmic trading in MT5

Go to Tools, Options, Expert Advisors. In current builds the key options read:

  • Allow algorithmic trading. The master permission for EAs to send orders.
  • Disable algorithmic trading when the account, profile or chart symbol/period has been changed. Useful safeguards that stop an EA trading on the wrong account after you switch logins.
  • Allow DLL imports. MT5 labels this potentially dangerous, and it is. Leave it off unless a trusted EA needs it.
  • Allow WebRequest for listed URL. Add only the specific URLs a trusted EA needs, such as a licence server or a news feed.

Older builds call these "automated trading" and the toolbar button "AutoTrading"; current builds use "Algo Trading". The function is the same. The toolbar button is the global switch: when it is off, no EA in the terminal can open trades, and a manual click on it is the fastest way to stop everything.

Attach the EA to a chart

Open a chart of the symbol and timeframe the EA expects. Check the exact symbol name, since many brokers add suffixes like EURUSD.r or EURUSDm that EAs with hard-coded names will not recognise. Drag the EA from the Navigator onto the chart.

In the dialog that appears:

  • Common tab: tick "Allow Algo Trading". Tick "Allow DLL imports" only if needed and trusted.
  • Inputs tab: set lot size or risk, stop-loss, take-profit, magic number and filters, or click Load to import a .set file from the vendor.
  • Dependencies tab (when shown): lists the DLLs and libraries the EA uses, which is a useful check on what it actually loads.

Click OK. The EA's name appears in the chart's top-right corner with a small status icon. In recent builds it is a hat-shaped icon that turns active when trading is allowed; if it looks greyed out or shows a warning, either the global button or the per-EA permission is off. To edit inputs later, right-click the chart and choose Expert Advisors, then Properties, or press F7.

Confirm sizing on a demo account before going live. As a check: an EA risking 1% of a €10,000 account with a 40-pip stop on EUR/USD risks €100. A pip on one standard lot of EUR/USD is worth $10, roughly €9.20 at an exchange rate of 1.0870, so the correct size is about 0.27 lots. If the Trade tab shows 2.7 lots, the risk input or the EA's pip calculation is wrong.

MT5-specific traps: account mode and filling policy

Netting versus hedging accounts

MT5 accounts run in one of two modes. In netting mode there is only one position per symbol: a buy of 1 lot followed by a sell of 0.4 lots leaves a 0.6-lot long. In hedging mode, each trade is a separate position and you can hold buys and sells on the same symbol simultaneously. EAs written for MT4-style logic usually assume hedging. Run them on a netting account and they may merge positions, close the wrong amount, or fail outright. US-regulated accounts must follow NFA FIFO and no-hedging rules, so expect netting-style behaviour there. Your account type is shown in the Navigator and in the terminal's title or account details. Our explainer on forex hedging covers the trading side of this distinction.

Order filling policy

MT5 lets brokers specify how orders are filled: Fill or Kill, Immediate or Cancel, or Return. An EA that requests a filling type your broker's symbol does not support gets error 10030 ("unsupported filling mode"). Well-written EAs query the symbol's allowed filling modes; older or careless ones hard-code one. If you see this error, look for a filling-mode input in the EA's settings or ask the developer for a fix.

Important risk point: an installed EA can open, size and close trades without asking you. A wrong input, an untrusted file or a strategy that averages into losers can damage an account quickly, and leverage magnifies every loss. Retail leverage is capped at 30:1 on majors for UK, EU and Australian clients and 50:1 in the US, but offshore accounts may offer far more, which makes mistakes more expensive. Most retail CFD and forex accounts lose money. Test on demo, start small and know how to switch Algo Trading off instantly.

Reading MT5 error codes

When an EA fails to trade, the Experts and Journal tabs in the Toolbox show a return code. These are the ones you will meet most often:

CodeMeaningUsual fix
10027Algo trading disabled by the client terminalTurn on the Algo Trading button
10030Unsupported filling modeChange the EA's filling setting or update the EA
10016Invalid stopsStops too close to price; check the symbol's stop level and digits
10014Invalid volumeLot size below minimum, above maximum or not a valid step
10019Not enough moneyReduce size or risk; check leverage
10018Market closedTrading outside the symbol's session

Messages like "cannot load indicator" or "cannot open file" mean a dependency is missing or misnamed; recheck the folders from the first table.

Keeping the EA online, and what comes next

An MT5 EA only runs while the desktop terminal is open and connected. The mobile and web versions of MT5 cannot run EAs at all. To keep it running around the clock, use a Windows VPS or the MetaQuotes virtual hosting service, which you can rent from the Navigator by right-clicking your account. Hosting near your broker's server reduces latency; see our comparison of forex VPS hosting. When migrating an EA to a hosted environment, the chart, EA and its settings are copied; files in MQL5\Files and some DLLs may not be, so check the EA works after migration.

Before trusting an EA with real money, backtest it properly in the Strategy Tester using real ticks and realistic delays, as described in our guide on how to backtest an EA in MT5. If you trade a funded account, confirm the firm allows the EA and that its worst-case drawdown fits the firm's limits; our article on prop-firm-safe expert advisors covers what firms typically restrict.

On a Mac, MetaQuotes distributes MT5 packaged to run on macOS, but some DLL-based EAs do not work in that environment. A Windows VPS is the simplest workaround. If you also use MT4, the process there differs in folder names and settings; see how to install an expert advisor on MT4.

Frequently asked questions

Where is the Experts folder in MT5?

Open MT5, click File, then Open Data Folder, then open MQL5 and Experts. That is the folder the terminal reads. The installation directory under Program Files contains a similar structure, but files placed there are generally not loaded. Each MT5 installation has its own data folder, so open it from the terminal you will trade with.

Why does my EA show but not trade in MT5?

First check the Algo Trading button on the toolbar and the "Allow Algo Trading" box in the EA's Common tab. Then read the Experts and Journal tabs for return codes such as 10027, 10030 or 10016. Also confirm the symbol name, timeframe and any session or news filters, and whether the EA expects a hedging account while yours is netting.

How do I install an EA bought from the MQL5 Market?

Log in to your MQL5.community account under Tools, Options, Community, then open the Market tab in the Toolbox and find the product under your purchases. Installing it places it in MQL5\Experts\Market, and it then appears in the Navigator. Each purchase has a limited number of activations, so reinstalling on new machines or VPSs uses them up.

Can I convert an MT4 EA to MT5?

Not automatically. MQL5 uses a different order and position model and returns indicator values through handles and buffers rather than direct function calls, so a programmer must rewrite or port the code, and the .ex4 alone is not enough. Some developers sell both versions. Any ported EA should be backtested and demo tested again because small differences can change behaviour.

What is the difference between netting and hedging in MT5?

On a netting account, all trades on a symbol combine into one position, so opposite orders reduce or reverse it. On a hedging account, each order is its own position, and buys and sells can coexist. EAs designed for one mode can malfunction on the other. US accounts must follow NFA FIFO and no-hedging rules regardless of platform features.

Can I run an EA on the MT5 mobile app?

No. Expert advisors only run in the desktop MT5 terminal on Windows, or in environments that emulate it, such as the macOS package or a VPS. The mobile and web terminals can view trades the EA opens and close them manually, but cannot run the EA. For continuous operation, use a VPS or MetaQuotes virtual hosting.

This article is general information, not personal financial advice. Figures such as spreads, fees, leverage and rules change; confirm them with the provider and check the provider is authorised for your country of residence.