Skip to content
MT5MT4soonTradingViewsooncTradersoonNinjaTradersoonPythonsoon

Algo Trading in MT5 Meaning: How Expert Advisors Trade for You

beginner9 min readOct 10, 20261 viewsUpdated Nov 1
Learn Forex from zero · lesson 45 of 47 · chapter 6

Algo trading in MT5 means a program places and manages the trades on your MetaTrader 5 account, not your own clicks. MetaQuotes officially calls this Automated Trading or Algorithmic Trading. The program is usually an Expert Advisor (EA), a trading robot that reads price quotes and opens or closes trades by itself, following rules written in advance.

This matters because a robot trades real money exactly the way it was told to. If one setting is wrong, it repeats that mistake on every trade, often while you are not watching.

What algo trading means in MT5, in plain words

Outside MT5, algorithmic trading means sending orders through pre-programmed instructions that take things like timing, price and volume into account. The point is to swap a human's in-the-moment judgment for a computer's speed and consistency.

MT5 gives that idea a concrete form. The rules live inside small applications written in MQL5, a programming language close to C++. MetaTrader's own help describes an EA as a mechanical trading system that automates both the analysis and the trading. That way the strategy is followed without emotion getting in the way.

Not every MQL5 program trades, though. The table shows the program types you will meet and what each one does.

Program typeWhat it doesPlaces trades?Where it runs
Expert AdvisorWatches prices and manages trades by its rulesYes, when algo trading is allowedOne active EA per chart
Custom indicatorDraws lines or signals on the chartNoSeveral on the same chart
ScriptDoes one job once, then stopsOnly if written toOn a chart, single run
ServiceBackground task, such as a custom price feedCan, but not tied to a chartStarts with the terminal

When someone says they algo trade on MT5, they almost always mean one thing. They have an EA attached to a chart, and it is allowed to trade.

What an EA does every time the price changes

Most EAs act when a new price quote arrives. That quote is called a tick, and each tick is the EA's cue to check its rules.

On each tick, the EA checks its rules against the latest price. If the conditions are not met, it does nothing and waits for the next tick. If they are met, it sends an order to the broker's server.

Once a trade is open, the EA keeps working on later ticks. It can move the stop loss, trail it behind the price, or close the trade when its exit rule is met. The figure below shows that cycle.

How an MT5 Expert Advisor checks its rules on every tick, sends a buy order, then manages the trade
Most ticks end in 'no'. The EA sends an order only when its rules are met, then manages the trade on later ticks.

The EA runs inside your own MT5 terminal, on your computer, not at the broker. The broker only receives the orders it sends. That is why the switches in the next section decide whether it can trade at all.

How an Expert Advisor gets permission to trade

Dropping an EA on a chart does not make it trade. Two separate switches must both be on:

  • The Algo Trading button on the terminal's toolbar. It turns automated trading on or off for the whole platform. Its icon is green when on and red when off. On Windows, Ctrl+E toggles it.
  • The Allow Algo Trading checkbox in the EA's own properties, on the Common tab.

If either switch is off, the EA cannot send orders. The diagram below shows the three combinations that confuse beginners (with both off, nothing trades either).

The two switches an MT5 Expert Advisor needs before it can trade
Orders go out only in case 1, where both switches are on.

From a trading idea to a running robot

Every EA starts as a rule a person wrote. Getting from that rule to live trading always follows the same order, shown below.

How a trading rule becomes a live MT5 Expert Advisor
  1. 1Write the rulee.g. buy on a close above the prior 5-candle high
  2. 2Code it in MQL5saved as a .mq5 source file
  3. 3Compilecreates the .ex5 file MT5 runs
  4. 4BacktestStrategy Tester on past prices
  5. 5Demo runsame settings, no real money
  6. 6Go liveboth switches on
Do not skip the testing and demo steps: they are where you catch a wrong setting before it costs money.

The source code is saved as a .mq5 file. MT5 cannot run it until it is compiled into an .ex5 file. If you download a ready-made EA, the .ex5 file is the part that actually runs.

The MQL5 editor comes with a debugger and a Strategy Tester. The tester replays past prices so you can see how the EA would have traded. This is called backtesting. It has a visual mode where you watch each trade appear on the chart. It can also optimize the EA's inputs, including a genetic-algorithm mode that searches through many combinations of settings.

You do not need to write code to take part. Ready-made EAs and indicators are shared through the MetaTrader Market and the free MQL5 Code Base. You install one, set its inputs, and test it the same way.

How to judge a ready-made EA before you run it

A downloaded EA trades with rules you did not write, so check these before it touches real money:

  • It doubles the lot after a loss (martingale) or adds trades against the move (grid). The backtest can look smooth because it hides one large loss that has not happened yet. Skip it, or cap the lot size in its inputs.
  • It has no stop-loss input. Do not run it live. Without one, nothing limits how much a single trade can lose.
  • Its lot size is hidden or fixed by the seller. Do not run it live until you can see the lot and work out what one losing trade costs.
  • Its backtest shows zero losing trades. Treat it as curve-fitted to old prices, not as proof it works.
  • It does not say which pair and timeframe it was built for. Backtest it on the pair and timeframe you plan to trade before you trust any results shown in its description.

Worked example: what one simple EA rule does to your account

All figures here are an illustrative example, on a US-dollar account. Suppose an EA trades the EUR/USD currency pair on the 1-hour chart with one rule: buy when a candle closes above the highest high of the 5 candles before it. Every trade has a 20-pip stop loss and a 40-pip take profit, where a pip is the small standard unit a price moves in. The lot input is 0.10 lots (a lot is the standard unit of trade size), and on EUR/USD at 0.10 lots one pip is worth $1. Say the bid-ask spread costs about 1 pip per trade.

EUR/USD 1-hour buy setup with a 20-pip stop loss and a 40-pip take profitIllustration
Take profit +40 pips1.1040EA buys at close1.1000Prior 5-high1.0997Stop loss −20 pips1.0980Buy signalTake profit hit
Illustrative prices. The Buy signal candle closes above the highest high of the 5 candles before it: that high is 1.0997, and the signal candle closes at 1.1000. The EA puts the stop 20 pips under the entry and the target 40 pips above it,

Over a week, the EA takes five trades. Two hit the take profit and three hit the stop loss. Here is the arithmetic, with the spread on its own line so you can see it:

One week of a simple EA at 0.10 lots on EUR/USD
Two winning trades2 × 40 × $1= $80
Three losing trades3 × 20 × $1= $60
Spread on five trades5 × 1 × $1= $5
Net result$80 − $60 − $5= $15
Week's net result+$15

Notice two things. The EA lost more trades than it won and still finished up, because each win was twice the size of each loss. And the spread took $5 of the $20 the rules earned, which is a quarter of it. Rules that trade often pay that cost often.

Now move the decimal point in the same example: type the lot input as 1.00 instead of 0.10, and each pip is worth $10. The chart below shows what the same three losing trades then cost. The robot follows its rule perfectly. It just applies a number ten times too large.

Cost of three stop-loss hits at 0.10 lots compared with 1.00 lots on EUR/USDIllustration
Lot input 0.10 ($1 per pip)
$60
Lot input 1.00 ($10 per pip)
$600
Same rule, same three losing trades. Moving one decimal point makes the loss ten times bigger.

Mistakes that cost beginners money, and how to avoid each

Trusting a perfect backtest. Optimization can tune the inputs until the past looks flawless, even with no losing trades at all. That proves the settings fit old prices. It does not prove they will work on new ones. Fix: after optimizing, test the same settings on a date range you did not optimize on. Then run them on a demo account before risking money.

Typing the wrong lot size. Fix: before the first live trade, open the EA's inputs and work out what one stop-loss hit costs in money. Compare that amount with your equity (account balance plus or minus open trades). If one loss would hurt, lower the lot size.

Switching algo trading off doesn't remove the EA. Turning the Algo Trading button off stops the EA from sending orders. The EA is still on the chart and starts trading again when you switch it back on. Trades it already opened stay open. Fix: if you want to stop using an EA for good, remove it from the chart, then decide what to do with its open trades.

Expecting two robots on one chart. A chart holds only one active EA. Fix: open a second chart for the second EA. Then make sure the two robots do not fight each other on the same pair.

Running the robot on a home computer that sleeps. If your computer switches off or loses its connection, the EA stops acting, including on trades it has open. A stop loss and take profit already placed with the order still work at the broker; what stops is the EA's own management, such as new entries, trailing or closing trades by its rules. MetaTrader recommends a VPS, which is a remote server that stays online, so the EA keeps running 24 hours a day. Fix: use a VPS, or only run EAs while you are at the screen.

What keeps working and what stops when the computer running an MT5 EA goes to sleep
The broker still holds your stop loss and take profit, but everything the EA does by itself stops until the computer comes back online.

Going live on day one. Fix: run every new EA on demo first, with the same lot settings you plan to use live. Compare its demo trades with what the backtest led you to expect.

If your EA is not placing trades, check in this order

Most silent robots fail one of these checks. Work through them from the top:

  1. Is the Algo Trading button on the toolbar green? If it is red, click it (or press Ctrl+E on Windows).
  2. Is Allow Algo Trading ticked on the Common tab of the EA's properties? Open the properties from the chart and check.
  3. If you have several charts open, are you checking the chart the EA is actually attached to?
  4. Did the code compile? Only an .ex5 file runs, and a .mq5 file with errors will not produce one.
  5. What does the platform's log say? When an EA cannot trade, MT5 records the reason as a message in the Experts and Journal tabs of the Toolbox panel. Read the latest lines there before changing any settings.
  6. Are the rule's conditions really being met? An EA that waits for a rare signal, such as a close above the prior 5-candle high, can sit idle for days, and that is correct behaviour. Check its inputs too, such as any trading-hours filter.

No trades in the Strategy Tester either? Then go through the inputs again. Make sure the symbol, timeframe and date range are the ones the EA was built for. Also check that the test period is long enough for its signal to appear at least once.

FAQ

Can I use my MT4 robot in MT5?

Not as it is. MT4 robots are .ex4 files written in MQL4, and MT5 cannot load them. You need a version made for MT5, or the code rewritten in MQL5. Ask whether an MT5 version exists before you download or buy.

Can I run my TradingView Pine Script strategy in MT5?

No. An Expert Advisor in MT5 must be an .ex5 file compiled from MQL5, so a Pine Script strategy cannot be loaded directly. Its logic has to be rewritten in MQL5 as an Expert Advisor. Then test the MQL5 version in the Strategy Tester and on demo, as you would any new EA.

Can I trade in MT5 with Python instead of MQL5?

Yes. MT5 can run Python scripts on a chart for data analysis and trading. For security reasons, though, a Python script needs explicit permission before it can place automated trades.

Can I run an Expert Advisor on the MT5 mobile app?

Not on the phone itself. An EA runs in a desktop MT5 terminal or on a VPS, which MetaTrader recommends so the strategy keeps trading 24 hours a day even when your own computer or connection is offline. On your phone, you can log in to the same account and see the trades the EA opens.

Part of Expert Advisors & automation: more guides, terms and free tools on this subject.