Why This Guide Exists
Every week I see traders download an Expert Advisor from a forum, drag it onto a chart, and wonder why nothing happens. The EA icon shows a frowning face. The Strategy Tester returns zero trades. The platform says "automated trading disabled." These are not strategy problems—they are platform configuration problems. This guide walks you through the complete MetaTrader 4/5 setup and MQL workflow so you can go from downloaded file to running, tested EA with full confidence.
What You Will Learn
- How to install MT4/MT5 and navigate the terminal layout
- Where to place EA and indicator files
- How to compile MQL4/MQL5 source code in MetaEditor
- How to enable AutoTrading and set EA permissions
- How to run a proper backtest and interpret results
- How to debug common platform errors
Prerequisites
- Platform version: MetaTrader 4 build 1390+ or MetaTrader 5 build 4000+ (download from your broker’s website, not a third-party site)
- A live or demo account: Any broker account works, but use a demo for testing
- MQL4/MQL5 source file: An .mq4 or .mq5 file, or an .ex4/.ex5 compiled binary
- MetaEditor: Comes bundled with the terminal; no separate installation needed
Step-by-Step Instructions
Step 1: Install MetaTrader and Log In
- Go to your broker’s website and click "Download MT4" or "Download MT5." Avoid generic downloads from metatrader4.com—always use your broker’s installer.
- Run the installer. Accept the default folder (
C:\Program Files\BrokerName MT4or... MT5). - Launch the terminal. You will see a login dialog. Enter your account number, password, and select the correct server. If you do not have a demo account, click "Open a demo account" inside the terminal (File → Open an Account).
- Once logged in, the Market Watch (left panel) populates with symbols. Right-click any symbol and select "Show All" to see every available instrument.
Step 2: Navigate the Terminal Layout
MetaTrader has four main areas:
| Area | Location | Purpose |
|---|---|---|
| Market Watch | Left panel | View symbols, bid/ask prices, spread; drag symbols onto charts |
| Navigator | Left panel (tab) | Browse installed indicators, EAs, scripts, and custom indicators |
| Chart Window | Center | Main price display; attach EAs and indicators here |
| Terminal | Bottom panel | Trades, Account History, Journal, Alerts, and Strategy Tester results |
Press Ctrl+M to toggle Market Watch, Ctrl+N for Navigator, and Ctrl+T for the Terminal panel.
Step 3: Place EA and Indicator Files
All custom files go into the MQL4 or MQL5 folder inside your terminal’s installation directory. To open this folder quickly:
- In the terminal, go to File → Open Data Folder (MT4) or File → Open Data Folder (MT5).
- You will see subfolders:
MQL4/Indicators,MQL4/Experts,MQL4/Scripts,MQL4/Include,MQL4/Files. - Copy your .ex4 or .ex5 files into the correct subfolder:
- EAs →
Experts - Custom indicators →
Indicators - Scripts →
Scripts - Include files (.mqh) →
Include
- EAs →
- If you have the source code (.mq4 or .mq5), place it in the same folder. MetaEditor will compile it into an .ex4/.ex5 automatically.
- Restart the terminal or right-click the Navigator and select Refresh. Your EA/indicator will now appear in the Navigator list.
Step 4: Compile MQL Source Code in MetaEditor
If you downloaded source code, you must compile it before use. Do not skip this step—pre-compiled .ex4 files from unknown sources can contain malware. Always compile from source when possible.
- Open MetaEditor: in the terminal, press F4 or go to Tools → MetaQuotes Language Editor.
- Click File → Open and navigate to your .mq4 or .mq5 file in the
ExpertsorIndicatorsfolder. - The source code opens in the editor. Click the Compile button (F7) or press F7.
- Watch the Toolbox panel at the bottom of MetaEditor. It shows errors and warnings. A successful compile shows "0 error(s), 0 warning(s)."
- If you see errors, double-click the error line—MetaEditor jumps to the offending code. Common errors: missing semicolons, undeclared variables, or missing include files.
- After successful compilation, the .ex4/.ex5 file is automatically placed in the correct subfolder. Return to the terminal and refresh Navigator.
Step 5: Enable AutoTrading and Set EA Permissions
This is the most common stumbling block. An EA will not trade until you explicitly allow it.
- In the terminal, go to Tools → Options (or press Ctrl+O).
- Click the Expert Advisors tab.
- Check the box "Allow Automated Trading" (MT4) or "Enable Automated Trading" (MT5).
- Below that, check "Allow DLL imports" only if your EA explicitly uses external DLLs (most EAs do not). Unchecked is safer by default.
- Check "Allow WebRequest" only if your EA fetches data from the internet (e.g., economic calendar). If enabled, add the URL to the list below.
- Click OK to save.
- Now drag the EA from Navigator onto a chart. A settings dialog appears. On the Common tab, ensure the following are checked:
- "Allow live trading"
- "Allow DLL imports" (if needed)
- "Allow modification of signals" (usually yes)
- Click OK. The EA icon in the top-right corner of the chart should show a smiling face. A frowning face means permissions are still blocked—recheck the Options and EA settings.
Step 6: Run the Strategy Tester
Never run an EA on a live account without backtesting first. The Strategy Tester is your safety net.
- Press Ctrl+R or go to View → Strategy Tester. The Tester panel opens at the bottom.
- Configure these fields:
- Expert Advisor: Select your EA from the dropdown.
- Symbol: The instrument to test (e.g., EURUSD).
- Model: Choose "Every tick" for the most accurate test. "Control points" and "Open prices only" are faster but less reliable.
- Timeframe: Usually M1 for tick-level accuracy, but you can test any timeframe.
- Date range: Set a start and end date. At least 6 months of data is recommended.
- Deposit: Match your intended account size (e.g., $10,000).
- 3D/Graphics: Uncheck for speed; check only if you want visual playback.
- Click Start. The tester runs and shows progress. When finished, the Results tab displays metrics: net profit, drawdown, Sharpe ratio, total trades, and more.
- Switch to the Graph tab to see the equity curve. A steadily rising curve with small drawdowns is ideal. A curve that drops sharply indicates risk issues.
- Use the Optimization tab to test multiple parameter combinations. Check "Optimization" before starting, then set min/max/step values for inputs.
Tips and Best Practices from Experience
- Always compile from source. Pre-compiled .ex4 files can hide malicious code. If the author provides only .ex4, ask for source or find an alternative.
- Use every-tick modeling for forex EAs. Open-prices-only modeling can miss stop-loss hits and slippage, giving false confidence.
- Run backtests over multiple market regimes. Test through trending, ranging, and volatile periods (e.g., 2020 COVID, 2022 rate hikes).
- Check the Journal tab during backtests. It logs initialization errors, order rejections, and other issues that the Results tab does not show.
- Disable "Visual mode" during optimization. It slows the tester dramatically. Enable it only for single-run debugging.
- Use a VPS for live EAs. Running an EA on your home PC risks internet drops and power outages. A $10/month VPS near your broker’s server reduces latency.
- Set up email and push notifications (Tools → Options → Email/Notifications) so the EA can alert you of errors or trades.
Common Mistakes and Troubleshooting
Mistake 1: EA Shows Frowning Face
Cause: AutoTrading is disabled at the platform level or the EA’s Common settings do not allow live trading.
Fix: Go to Tools → Options → Expert Advisors and check "Allow Automated Trading." Then right-click the chart, select Expert Advisors → Properties, and ensure "Allow live trading" is checked.
Mistake 2: Backtest Shows Zero Trades
Cause: The EA’s logic may require a specific market condition that never occurred in the test period, or the EA uses OrderSend() with incorrect parameters.
Fix: Run the backtest with Visual mode enabled. Watch the chart and the Journal tab. Look for "OrderSend failed" or "invalid stops" errors. Also check that the EA is not filtered by date or time conditions that exclude the test range.
Mistake 3: Compilation Errors in MetaEditor
Cause: Missing include files, syntax errors, or using MT4-specific functions in MT5 (or vice versa).
Fix: Read the error message carefully. If it says "cannot open #include file," locate the missing .mqh file and place it in the Include folder. If it says "undeclared identifier," check the variable name spelling. For cross-platform issues, use #ifdef __MQL4__ or #ifdef __MQL5__ to write conditional code.
Mistake 4: EA Does Not Trade on Live Account
Cause: The EA may be set to "Disabled" in the chart properties, or the broker requires a specific permission.
Fix: Right-click the chart, select Expert Advisors → Properties → Common, and verify all permissions are enabled. Also check the Journal tab for messages like "Expert Advisor stopped" or "OrderSend error 138 (requote)." Requotes indicate broker rejection due to price changes—consider using ORDER_FILLING_IOC or slippage settings.
Summary and Next Steps
You now have a complete workflow: install MetaTrader, place files, compile MQL code, enable AutoTrading, and run reliable backtests. This foundation lets you focus on strategy logic rather than platform struggles.
Next steps:
- Learn to read the Report tab in the Strategy Tester—focus on profit factor, recovery factor, and max drawdown.
- Explore optimization




