You have an Expert Advisor (EA) β whether you coded it yourself, downloaded our free bot, or bought one β and now you need to get it running on MetaTrader 5. This tutorial covers the whole process, from scratch, paying attention to the details that trip up beginners (the classic "I installed it but the bot does not trade"). We go from the file to the backtest to the deployment.
Prerequisite: you need MT5 installed (downloaded from your broker, not from the generic site β you need the right broker's server) and the EA file, which has the extension .ex5 (compiled) or .mq5 (source code). If you have not picked a broker yet, see our reviews of brokers with MT5.
01Step 1: Put the EA in the right folder
MT5 only sees bots that sit in the correct data folder. The safest way to get there:
In MT5, go to File β Open Data Folder. That opens the file explorer exactly at the folder MT5 uses β it avoids the common mistake of dropping the EA into the wrong installation folder.
In the folder that opened, go into MQL5 β Experts and paste your bot's file there (.ex5 or .mq5). If it is an indicator, it goes in Indicators; if it is a script, in Scripts.
Go back to MT5. In the Navigator panel (Ctrl+N if it is not visible), right-click "Expert Advisors" and choose Refresh. Your bot should show up in the list.
02Step 2: Enable Auto Trading
This is the step behind most "my bot does nothing" complaints. MT5 has a master automated trading button that has to be green/on. Without it, the EA loads on the chart but never sends an order.
The button sits in the top toolbar, labeled "Algo Trading" (or "Auto Trading" in older versions). Green = on. Red = off. Click to toggle.
Two permission levels: beyond the global button, each EA has its own permission. When you drag the bot onto the chart (next step), in the "Common" tab check "Allow Algo Trading". Both have to be active.
03Step 3: Drag the EA onto the chart
Open the chart of the asset you want to trade (e.g. Brazil's WIN mini index future, EURUSD). In the Navigator, drag the EA onto the chart (or double-click it). A settings window will open.
Check "Allow Algo Trading". The other options (allow DLL imports and so on) are usually left unchecked for safety, unless the bot requires them.
This is where the bot's variables live (lot size, stop, take profit, moving average periods and so on). Set them according to the strategy. Always start with the minimum lot.
Click OK. If everything went well, you get a smiley face π in the top right corner of the chart β it means the EA is active. If you see a π or a β, auto trading is not enabled at some level.
The green light of success: the EA icon smiling in the corner of the chart + the bot's name next to it. If you see that, the bot is watching the market and will trade according to its rules.
04Step 4: Backtest in the Strategy Tester (BEFORE trading)
This step is non-negotiable. Never run an EA on a live account without testing it on historical data first. MT5 has a built-in simulator β the Strategy Tester β that runs your bot over years of past data in seconds.
Open it with View β Strategy Tester (or Ctrl+R). Configure:
- Expert: select your bot
- Symbol: the asset (e.g. WIN, EURUSD)
- Period: the timeframe (M5, M15, H1...)
- Date range: use at least 2-3 years, covering uptrends, downtrends and ranges
- Modelling: "Every tick based on real ticks" is the most accurate (and the slowest)
Read the drawdown, not just the profit: a curve that rises beautifully but with a 40% drawdown is a time bomb β it means that at some point you would have lost 40% of the account. Look for low drawdown (ideally under 20% for a small trader) with a relatively smooth equity curve. A "too good" curve, a perfect straight line, is usually a sign of overfitting.
05Step 5: Optimization (with extra care)
The Strategy Tester also optimizes β it tests hundreds of parameter combinations to find the "best" one. It is powerful and dangerous in equal measure. The risk is overfitting: you find the parameters that would have been perfect in the past but fail in the future, because they were fitted to noise, not to signal.
How to optimize without fooling yourself:
- Split the data: optimize on 70% of the period (in-sample) and validate on the remaining 30% (out-of-sample) that the bot has never "seen".
- Be suspicious of isolated peaks: if one set of parameters makes far more than its neighbors, that is statistical luck, not robustness. Prefer broad regions of parameters that perform similarly.
- Less is more: a bot with 3 optimizable parameters is more robust than one with 15. Every extra parameter is one more chance to overfit.
Do not have a bot to install yet?
Download our sample EA, commented line by line, ready to run with this tutorial.
06Step 6: VPS β why your bot needs one
Here is what separates a hobby from a serious operation. If you run the EA on your personal computer, the bot only works while the machine is on, connected to the internet, and MT5 is open. Power cut? Went to sleep and shut the PC down? Internet dropped? The bot stops β possibly with an open position and nobody managing it.
The solution is a VPS (Virtual Private Server) β a computer in the cloud, on 24/7, where your MT5 runs without interruption. Advantages:
- 24/5 availability (the forex market trades around the clock on business days)
- Low latency β a VPS close to the broker's server executes orders faster
- Independence from your machine β you can shut the PC down and the bot keeps going
Many brokers offer a free VPS to traders who keep a minimum volume. Alternatively, there are forex-specialized VPS providers starting at a few dollars a month. For HFT/scalping, pick a VPS in the same region as your broker's server (usually London or New York).
07Final checklist before going live
Before letting the bot trade real money, confirm:
- β 2-3 year backtest with acceptable drawdown (<20%)
- β Out-of-sample validation (tested on data it was not optimized on)
- β Ran on a demo account for at least 1 month
- β Demo behavior matches the backtest
- β Auto trading enabled at both levels (global + EA)
- β Lot size set to the minimum
- β VPS configured (if you are trading seriously)
- β You understand what the bot does and when it stops
08Frequently asked questions
My EA is not trading, what do I do?
Check in this order: (1) the "Algo Trading" button is green in the toolbar; (2) in the EA settings, "Allow Algo Trading" is checked; (3) the smiley face π in the corner of the chart; (4) the market is open; (5) the bot's parameters make sense (lot > 0). The problem is almost always item 1 or 2.
What is the difference between .ex5 and .mq5?
.mq5 is the source code (you can edit and compile it). .ex5 is the compiled file (executable, not editable). Both run on MT5; if you only have the .mq5, MT5 compiles it to .ex5 automatically when loading.
Do I have to pay for a VPS?
Not necessarily. Many brokers offer a free VPS if you keep a minimum volume or balance. If not, forex VPS plans start at a few dollars a month. If you only trade during business hours and keep an eye on things, you can start without a VPS β but for 24/5 operation it is practically mandatory.
Can I run the bot on the mini index future (WIN)?
Yes, as long as your broker offers MT5 with access to Brazil's B3 exchange. Then you open the WIN/WDO chart and run the EA as usual. See our guide to day trading on the B3 to understand that market.
Does a backtest guarantee I will profit?
No. A backtest shows how the bot would have behaved in the past β it is necessary, but not sufficient. The future market differs from the past. That is why a demo account for 1 month is essential: it tests the bot under real, current conditions before you risk capital.
Get a bot running today
Download our sample EA (Python + MQL5) and follow this step-by-step tutorial.
Download the free bot β