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)
- Open MetaTrader 5
- Click File → Open Data Folder
- Navigate to
MQL5 → Experts - Copy your .ex5 or .mq5 file into this folder
- Restart MetaTrader 5 (or refresh Navigator)
- 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:
- Place the .mq5 file in
MQL5\Experts - Open MetaEditor (F4 in MT5 or Tools → MetaQuotes Language Editor)
- Find your .mq5 file in Navigator
- Double-click to open it
- Click Compile button (or press F7)
- Check for errors in the Toolbox window
- If successful, a .ex5 file will be created automatically
Using Your EA in MetaTrader
Attaching to a Chart
- Open a chart for your desired symbol and timeframe
- In Navigator, expand Expert Advisors
- Drag your EA onto the chart
- 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
- Open Strategy Tester (Ctrl+R or View → Strategy Tester)
- Select your EA from the dropdown
- Choose symbol and timeframe
- Set date range for testing
- Click Start
- 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
Next Steps
Once your EA is deployed:
- Run comprehensive backtests over multiple years
- Analyze performance metrics (profit factor, drawdown, Sharpe ratio)
- Optimize parameters using Strategy Tester
- Forward test on demo account for at least 1 month
- Start live trading with minimal lot sizes
- Scale up gradually as you gain confidence