Exporting to MetaTrader

Learn how to export your Expert Advisor and deploy it to MetaTrader 5 for backtesting and live trading.

Export Options

.mq5 File (Source Code)

Exports the MQL5 source code of your EA. You can:

  • View and edit the generated code
  • Compile it yourself in MetaEditor
  • Customize advanced features not available in the builder
  • Learn MQL5 by examining the generated code

Best for: Developers, advanced users, learning

.ex5 File (Compiled)

Exports a compiled, ready-to-use Expert Advisor. Just drop it into MT5 and start using it.

  • No compilation needed
  • Faster deployment
  • Code is protected (cannot be viewed)
  • Ready for immediate use

Best for: Quick deployment, non-technical users

How to Export

Step 1: Complete Your EA

Ensure your EA has:

  • At least one indicator (if using indicator-based signals)
  • Entry signals (Open Buy and/or Open Sell)
  • A stop loss strategy (required for risk management)
  • Money management configuration

Step 2: Click Export

In the EA Builder, click the Export button.

Step 3: Choose Format

Select whether you want:

  • Download .mq5 - Source code
  • Download .ex5 - Compiled (requires server-side compilation)

Step 4: Save the File

Your browser will download the file. Save it to a location you'll remember.

Installing in MetaTrader 5

Method 1: Via File Menu (Recommended)

  1. Open MetaTrader 5
  2. Click File → Open Data Folder
  3. Navigate to MQL5 → Experts
  4. Copy your .ex5 or .mq5 file into this folder
  5. Restart MetaTrader 5 (or refresh Navigator)
  6. Find your EA in Navigator under Expert Advisors

Method 2: Direct Path

Default MT5 data folder locations:

  • Windows: C:\Users\[YourName]\AppData\Roaming\MetaQuotes\Terminal\[InstanceID]\MQL5\Experts
  • Mac: ~/Library/Application Support/MetaQuotes/Terminal/[InstanceID]/MQL5/Experts

If You Downloaded .mq5 (Source)

You need to compile it:

  1. Place the .mq5 file in MQL5\Experts
  2. Open MetaEditor (F4 in MT5 or Tools → MetaQuotes Language Editor)
  3. Find your .mq5 file in Navigator
  4. Double-click to open it
  5. Click Compile button (or press F7)
  6. Check for errors in the Toolbox window
  7. If successful, a .ex5 file will be created automatically

Using Your EA in MetaTrader

Attaching to a Chart

  1. Open a chart for your desired symbol and timeframe
  2. In Navigator, expand Expert Advisors
  3. Drag your EA onto the chart
  4. A settings dialog will appear

EA Settings Dialog

The dialog has several tabs:

Common Tab

  • Allow Algo Trading: Must be checked!
  • Allow DLL Imports: Usually not needed
  • Timeframe: Select appropriate timeframe

Inputs Tab

Any configurable parameters will appear here. Most AlgoBuilder EAs have preset parameters, but you may see options like:

  • Magic Number (for tracking trades)
  • Slippage tolerance
  • Custom settings (if you edited the code)

Testing Tab

For optimization and backtesting settings (used in Strategy Tester).

Enable Algo Trading

Make sure the Algo Trading button in the MT5 toolbar is enabled (green icon). Your EA will show a smiley face icon in the top-right corner of the chart if running correctly.

Backtesting Your EA

  1. Open Strategy Tester (Ctrl+R or View → Strategy Tester)
  2. Select your EA from the dropdown
  3. Choose symbol and timeframe
  4. Set date range for testing
  5. Click Start
  6. Review results in the tabs: Results, Graph, Report

Important Backtest Settings

  • Modeling: Use "Every tick" for most accurate results
  • Spread: Set realistic spread for your broker
  • Initial Deposit: Test with realistic account size

Common Issues

EA Not Appearing in Navigator

  • Ensure file is in correct folder (MQL5\Experts)
  • Restart MetaTrader 5
  • Right-click Navigator → Refresh
  • Check file extension (.ex5 or .mq5)

Compilation Errors (.mq5)

  • Make sure you downloaded the .mq5 file correctly
  • Use latest MetaEditor version
  • Check compilation output for specific error messages

EA Shows Sad Face Icon

  • Enable Algo Trading in MT5 toolbar
  • Check "Allow Algo Trading" in EA settings (Common tab)
  • Verify account allows automated trading

EA Not Trading

  • Check that entry signals are being met
  • Verify account has sufficient margin
  • Ensure trading hours align with prevent opening strategies
  • Check Experts log in Toolbox for error messages

Best Practices

  • Always backtest first - Never deploy directly to live account
  • Test on demo account - Verify real-time behavior matches expectations
  • Monitor initially - Watch the first few trades closely
  • Keep backups - Save your .mq5 files in case you need to re-export
  • Version control - Keep track of different versions of your EA
Important: Backtesting results do not guarantee future performance. Always use proper risk management and start with small position sizes.

Next Steps

Once your EA is deployed:

  1. Run comprehensive backtests over multiple years
  2. Analyze performance metrics (profit factor, drawdown, Sharpe ratio)
  3. Optimize parameters using Strategy Tester
  4. Forward test on demo account for at least 1 month
  5. Start live trading with minimal lot sizes
  6. Scale up gradually as you gain confidence