How to Install and Run Expert Advisors in MT4/MT5

Learn the exact steps to install and run Expert Advisors on MetaTrader 4 and 5, including folder placement, permissions, debugging, and best practices for.

how-to-install-and-run-expert-advisors-in-mt4-mt5

Introduction

Expert Advisors (EAs) are automated trading programs written in MQL4 or MQL5 that can execute trades, manage positions, and apply money management rules without manual intervention. Installing and running an EA correctly is the first real skill every automated trader must master. Many beginners copy the EA file into the wrong folder or forget to enable AutoTrading, then wonder why nothing happens. This guide walks you through the exact process for both MetaTrader 4 and MetaTrader 5, from file placement to live execution, with practical tips I've learned from years of debugging EA installations.

Prerequisites

Before starting, ensure you have:

  • MetaTrader 4 or 5 platform installed from your broker’s website. MT4 and MT5 are separate platforms; an EA compiled for MT4 (EX4) will not run on MT5 (EX5), and vice versa. Always download the correct version from your broker.
  • A live or demo trading account logged into the platform. You cannot attach an EA to a chart without a running account. For testing, a demo account with sufficient virtual funds is recommended.
  • The EA file – typically an .ex4 (MT4) or .ex5 (MT5) compiled file, or the source .mq4/.mq5 file if you need to compile it yourself using MetaEditor (F4).
  • Basic understanding of file paths – you'll need to navigate to the MQL4 or MQL5 folder inside your MetaTrader installation directory. The File → Open Data Folder command is your best friend here.

Step-by-Step Instructions: Installing and Running an EA

Step 1: Locate the Correct Folder

The most common mistake is placing EA files in the wrong directory. The correct location is inside your MetaTrader installation folder, under MQL4\Experts (for MT4) or MQL5\Experts (for MT5).

  1. Open MetaTrader and go to File → Open Data Folder (or press Ctrl+Shift+D). This opens the platform's sandboxed data directory, which is separate from the program files folder and avoids permission issues on Windows.
  2. Navigate to MQL4\Experts (MT4) or MQL5\Experts (MT5). If the folder does not exist, create it manually. On some broker installations, the folder may be named Experts directly under the platform root.
  3. Copy your EA file (.ex4 or .ex5) into this folder. Do not place it in Indicators or Scripts – only the Experts folder works. If the EA comes with supporting files (e.g., custom indicators, DLLs), place those in their respective folders.

Step 2: Refresh the Navigator Panel

After placing the file:

  1. In MetaTrader, open the Navigator panel (View → Navigator or Ctrl+N).
  2. Right-click anywhere inside the Navigator and select Refresh. Your EA should now appear under the Expert Advisors branch. If it doesn't, check that the file extension matches the platform version.
  3. If it doesn't appear, double-check the file extension and folder path. Sometimes the platform caches the list; restarting MetaTrader also works. For MT5, ensure the file is compiled as EX5 (not EX4).

Step 3: Attach the EA to a Chart

  1. Drag the EA from the Navigator onto any chart, or double-click it and click OK. The chart should have enough historical data for the EA to initialize properly – at least 100 bars minimum.
  2. The Expert Advisor – Input Parameters window appears. Review the inputs – many EAs have configurable settings like lot size, stop loss, or trading hours. Adjust as needed, then click OK. Some EAs have hidden parameters; use the Show All checkbox to reveal them.
  3. A smiley face icon should appear in the top-right corner of the chart, indicating the EA is attached and running (if AutoTrading is enabled). A frowny face means it's attached but disabled. A gray face means the EA is not attached at all.

Step 4: Enable AutoTrading

This is the most critical step. An EA attached to a chart will not execute trades unless AutoTrading is globally enabled.

  1. In the main toolbar, click the AutoTrading button (a green triangle or a hand with coins icon). It should turn green or show "AutoTrading enabled." In MT4, the button is typically on the toolbar; in MT5, it's in the same location.
  2. Also verify that the EA itself has permission to trade: in the Navigator, right-click the EA → PropertiesCommon tab, and check "Allow live trading" and "Allow DLL imports" (only if the EA uses external DLLs). Some brokers disable DLL imports by default for security.
  3. For MT5, you must also go to Tools → Options → Expert Advisors and ensure "Allow automated trading" is checked. In MT4, this setting is under Tools → Options → Expert Advisors as well.
Permission Location Default State Action Required
Global AutoTrading Toolbar button Disabled Click to enable (green icon)
Allow Live Trading EA Properties → Common Enabled Verify it's checked
Allow DLL Imports EA Properties → Common Disabled Enable only if EA requires DLL

Step 5: Verify the EA is Running

Once attached and AutoTrading is on, check the Experts tab in the Terminal window (View → Terminal → Experts). You should see log entries like "EA loaded successfully" or "init() called." If the EA makes trades, they appear in the Trade tab. If you see errors such as "not enough money" or "invalid stops," the EA is running but cannot execute due to account constraints. For example, a minimum lot size of 0.01 on a $100 account with 1:500 leverage may still fail if the EA tries to open 0.1 lots.

Tips and Best Practices from Experience

  • Always test on demo first. Run the EA on a demo account for at least a week to ensure it behaves as expected before going live. Use the Strategy Tester for quick backtests, but real tick data in demo gives the truest picture. Demo accounts often have different liquidity and spread conditions, so factor that in.
  • Use the Data Folder method. The File → Open Data Folder approach avoids permission issues on Windows. Never manually copy files into C:\Program Files – always use the data folder. This also ensures your EAs survive platform updates.
  • Check the EA’s input parameters carefully. Many EAs have hidden risk settings. For example, a default lot size of 0.1 may be too large for a $500 account. Always review inputs before attaching. Look for parameters like RiskPercent, LotSize, and MaxSpread.
  • Keep a backup of your EA files. Brokers sometimes reset the data folder during platform updates. Store your .ex4/.ex5 files in a separate folder on your desktop. Also keep the source .mq4/.mq5 files if you have them.
  • Monitor the Journal tab. The Journal tab (in Terminal) shows critical errors like "OrderSend failed" or "invalid ticket." These help you diagnose why an EA isn't trading. Common error codes include 130 (invalid stops), 138 (requote), and 148 (too many trades).

Common Mistakes and Troubleshooting

Mistake 1: EA Not Appearing in Navigator

Cause: File placed in wrong folder or wrong extension.

Fix: Verify the file is in MQL4\Experts (not MQL4\Indicators). Ensure the extension is .ex4 for MT4 and .ex5 for MT5. Refresh Navigator or restart the platform. If the file is an .mq4 source file, compile it first using MetaEditor (F4 → Compile).

Mistake 2: EA Shows a Frowny Face or "Disabled"

Cause: AutoTrading is off globally, or the EA's "Allow live trading" is unchecked.

Fix: Click the AutoTrading button in the toolbar. Then right-click the EA in Navigator → Properties → Common → check "Allow live trading." Also check Tools → Options → Expert Advisors → "Allow automated trading."

Mistake 3: EA Attached but No Trades

Cause: Market conditions don't meet the EA's entry criteria, or the EA has a bug.

Fix: Check the Experts tab for log messages. If the EA prints "no signal" or "waiting for conditions," it's working correctly. If it prints "OrderSend error 130" (invalid stops), check your broker's minimum stop distance. Test with a simple EA like Moving Average Cross to isolate the issue. Also verify the chart timeframe matches the EA's expected timeframe.

Mistake 4: "Cannot load DLL" Error

Cause: The EA uses external DLLs but "Allow DLL imports" is unchecked.

Fix: Right-click the EA → Properties → Common → check "Allow DLL imports." Be cautious: only enable this for trusted EAs, as DLLs can access your system. Some brokers block DLL imports entirely for security; contact support if needed.

Mistake 5: EA Works in Strategy Tester but Not Live

Cause: Differences in tick data, spread, or execution model between tester and live.

Fix: The Strategy Tester uses historical ticks and may not replicate real-time conditions. Test on a demo account with the same broker settings. Common issues include slippage, requotes, and latency. Ensure the EA uses MODE_TICKS or real-time price checks.

Summary and Next Steps

You now know how to install Expert Advisor MetaTrader 4 and 5, attach it to a chart, enable all necessary permissions, and troubleshoot basic issues. The key steps are: place the EA in the correct Experts folder, refresh Navigator, attach to a chart, and enable AutoTrading globally and per EA. Always test on demo first and monitor the Experts and Journal tabs for errors.

For next steps, consider learning how to customize EA input parameters, run multi-EA setups on different charts, or use the Strategy Tester to optimize settings. If you encounter more advanced errors, such as "OrderSend error 138" (requote) or "out of memory," these typically relate to broker connectivity or platform resource limits, not installation issues. For requotes, reduce lot size or increase slippage tolerance. For memory issues, close unused charts and reduce the number of running EAs.

Frequently Asked Questions

Why does my EA show a frowny face after attaching it to a chart?

A frowny face means the EA is attached but disabled. This usually happens when AutoTrading is off globally (check the toolbar button) or the EA's "Allow live trading" permission is unchecked in its Properties → Common tab. Enable both settings, then the face should turn into a smiley.

Can I run multiple EAs on the same chart?

No, MetaTrader only allows one EA per chart. To run multiple EAs, open separate charts for each EA. You can use different timeframes or symbols for each chart to avoid conflicts.

My EA worked on demo but fails on a live account. What's wrong?

Common reasons include: different broker settings (e.g., minimum stop distance, lot size restrictions), different spread conditions, or the EA requiring DLL imports that the live broker blocks. Test the EA on a demo account from the same broker first, and compare settings.

How do I know if an EA is using DLL imports?

Check the EA's source code or documentation for functions like `#import` or `DLL` calls. If you're unsure, enable "Allow DLL imports" only if you trust the EA's source. Malicious

Community

Clap for the article and open comments only when you want to read them.

0 claps0 comments

Related articles