An Expert Advisor (EA) opens and closes trades with orders, and it protects them with a stop loss and a take profit. How those work in MetaTrader 5 (MT5), and where they can let you down, decides how much a losing trade really costs. This page covers both.
When either is reached, MT5 closes the whole position. Which price counts depends on the direction:
| Position | Stop loss and take profit are checked against |
|---|---|
| Buy | the Bid (the price you'd sell at to close it) |
| Sell | the Ask (the price you'd buy at to close it) |
So a sell can be stopped out by the spread widening, even if the chart (drawn from the Bid) never touched the stop.
A stop loss is meant to limit a loss to roughly its size. It doesn't guarantee it. When the price reaches the stop, the position is closed at the next price available. In a fast or gapping market, such as over a weekend or around big news, that price can be worse than the stop, so the real loss can be bigger. The close can also come late, or not at all.
That's why the loss at the stop is an estimate, never a ceiling.
If an EA's stop is virtual, its protection depends on the computer it runs on. That's one reason to decide where the EA will run, such as on a VPS, before going live.
Brokers set two minimum distances for each symbol, shown in the Specification window in points:
An EA whose stop is tighter than the stops level will have its orders refused. MT5's Journal shows these as "invalid stops".
Market orders buy or sell now, at the current price. How the price is agreed depends on the broker's execution type, shown in the Specification window:
Pending orders wait for a price. MT5 has six:
| Order | Opens a | When |
|---|---|---|
| Buy Limit | buy | the Ask falls to the order price or lower |
| Sell Limit | sell | the Bid rises to the order price or higher |
| Buy Stop | buy | the Ask rises to the order price or higher |
| Sell Stop | sell | the Bid falls to the order price or lower |
| Buy Stop Limit | Buy Limit order | the Ask reaches the stop price |
| Sell Stop Limit | Sell Limit order | the Bid reaches the stop price |
An order can be set to last until cancelled, until the end of the trading day, or until a time or day you choose. Separately, each symbol has a rule for how long pending orders, stops and targets stay in place, shown in the Specification window:
On a symbol where stops are deleted each day, an EA that sets its stop once and leaves it would be left with no stop. Check this rule in the Specification window for every symbol the EA trades.
When there isn't enough volume to fill an order at once, the filling policy decides what happens:
Each symbol allows some of these and not others. An EA that asks for one the symbol doesn't allow has its orders refused.
MT5 details checked against MetaQuotes' MetaTrader 5 help and MQL5 reference, October 2026. Examples are illustrative; read your own broker's figures.
Trading involves risk. Only trade with money you can afford to lose. This page is educational and is not financial advice.

© 2026 The Robotic Trader. All rights reserved.