Manage Trades You Open Yourself in MT5: What a Trade Manager EA Does
Short answer: a trade manager EA manages the trades you open by hand in MetaTrader 5 and never opens one itself. You decide when to buy or sell. After that, the EA can set a safety stop if the trade has none, close part of it, move the stop to the entry price (breakeven), trail the stop behind the price and close the trade at a time you set. Each of these changes a stop or a target, or closes the trade; none of them opens a position.
Most guides in this academy assume the EA opens its own trades. This one does not. Convert a manual trading strategy into an MT5 EA automates your entries; this guide deliberately leaves the entries to you and covers only what happens to a trade after you open it.
Part of the MQL5 and Expert Advisors academy.
Who Opens the Trade Decides What the EA Does
| You open, the EA manages | The EA opens and manages | |
|---|---|---|
| Who decides the entry | You, with a click on your computer or your phone | The EA's entry rules |
| What the EA may send | A changed stop or target, a full or partial close | A new order, a changed stop or target, a close |
| Position size | You choose it when you open the trade | The EA computes it from the stop |
| The first stop | Only there if you set one, until the EA sees the trade | Sent with the order |
| Where the rules live | One trade manager EA on its own chart | Inside the strategy's EA |
| Read next | This guide | EA risk management |
Two consequences follow from the first row.
- The size is yours. A trade manager can close part of a trade, but it never adds to one or sizes it for you, so the size has to fit the stop you plan to use. The lot formula from the stop distance, the tick value and the volume step is in EA risk management; work it out before you click.
- There is a moment without a stop. An EA that opens a trade sends the stop with the order. When you open the trade without one, the trade has no stop until the manager sees it. That gap is why the safety stop comes first.
MetaTrader 5 runs one EA per chart [1], so a trade manager needs a chart of its own. Run one trade manager per account, so two of them never move the same stop.
After You Open a Trade: The Safety Stop
When the EA first sees a trade without a stop loss, it sets one at the distance you chose. It can do the same for a missing take profit. A stop or a target you set yourself is kept: the safety stop is there for the trade you opened in a hurry, not to overrule your plan.
Choose the distance from the market you trade, not from habit, and make it the same distance you used to size the trade. A safety stop that is far wider than the stop you sized for puts more money at risk than you meant to.
Your broker has the last word on the level. Every symbol has a smallest distance between the price and a stop, the stops level [2]. When your distance is closer than that, the stop has to go further away than you asked, or the broker refuses it. If the broker refuses every level, or the price has already passed the place where the stop would go, the trade is left without the EA's stop: set one yourself. Why brokers refuse a stop, and how the stops level is read: MT5 error 10016 (invalid stops).
While the Trade Runs: Partial Close, Breakeven and Trailing Stop
These three rules act on a trade that is already open and already has a stop. Each one only moves the stop or closes volume.
Close part of the trade
A partial close takes a share of the position off at a level, at a distance from the entry, or at a price you choose; the rest stays open. The part is rounded down to the broker's volume step [2]. When the part is smaller than the smallest volume the broker allows, there is nothing to close at that level, so it is skipped.
That rounding decides how small a trade can be. With a volume step and a minimum of 0.01 lots:
| Position | Close half | What is closed |
|---|---|---|
| 0.01 lots | 0.005 | Nothing: below the minimum |
| 0.03 lots | 0.015 | 0.01 lots, rounded down |
| 0.10 lots | 0.05 | 0.05 lots |
If you plan to close half, open at least twice the minimum volume.
Move the stop to the entry (breakeven)
Once the price has moved far enough your way, the stop moves to the entry price. From then on, a return to the entry closes the trade at its stop instead of letting it run back to the original one. A stop at the entry is still a stop order: in a gap or a fast market it is filled at the next available price, which can be worse than the entry.
Follow the price (trailing stop)
A trailing stop follows the best price and never moves back. It can trail by a fixed distance, by a multiple of ATR, or behind the last candles. When the price comes back to it, the trade closes at the moved stop. A trailing stop changes where a trade exits, not what it risked when you opened it.
Decide which rule moves the stop first. Breakeven and the trailing stop both move the same stop, and neither moves it back. If the trailing stop starts closer than your breakeven trigger, it can already be past the entry by the time breakeven would act, and breakeven then has nothing to do. Set the distances so the order matches your plan.
When the Trade Should End: Close at a Time
A time close shuts every trade the EA manages at a set time, for example before the weekend or before a session you do not want to hold through. It exists because a stop does not cover a gap: when the market reopens away from your stop, the stop is filled at the first price available.
Check which clock the time uses. MetaTrader 5 shows the broker's server time, which is often not your local time, and a trade manager running on a VPS may sit in yet another time zone.
Across the Account: What an Account-Level Stop Can and Cannot Do
The rules above work trade by trade. An account-level stop works on the whole account: it watches the account's equity [3], which includes every open trade, and acts when the equity falls to a limit you set for the day or from a peak.
What an EA can do at the limit: close the open trades on the account and delete waiting orders.
What no EA can do:
- Stop you from placing a trade. MQL5 has no function that locks the order buttons of the terminal. The most an EA can do is close a trade after it opens.
- Choose the closing price. The price can move between the limit and the close: a gap, a fast market, or a market that is closed when the limit is reached. The loss can be larger than your limit.
- Act while the terminal is off. If MetaTrader 5 is closed or disconnected, nothing watches the account.
- Know a funded account's rules for you. When the day starts, and whether the limit is measured on balance or on equity, differ between accounts. Keeping to those rules stays your responsibility: see Prop firm EA rules for MT5.
How such a guard is written in MQL5, with the day's start and the equity check, is shown in the daily-loss guard of EA risk management.
What a Trade Manager EA Needs to Work
- A running terminal. It works only while MetaTrader 5 is running on your computer or a VPS, connected, with Algo Trading on. When the terminal is closed or the EA is removed, nothing is managed. For a terminal that keeps running: VPS for an Expert Advisor.
- Trades from your phone are fine, once the terminal sees them. The EA runs in the terminal on your computer or VPS, not on your phone.
- One manager per account, on its own chart, as above.
- No undo. A trade manager cannot undo a trade you close, and it never reopens one.
- A demo account first. Open a small trade by hand without a stop and watch the safety stop appear. Then try each rule you switched on, one at a time, before you use it on a live account.
The AlfaTactix Trade Manager
The AlfaTactix Trade Manager is a trade manager EA for MetaTrader 5 built this way: it has no entry rules, and its code contains no order that opens a trade. It only changes a stop or a target and closes a trade or part of it. You switch on the steps you want on the site and get one file for MetaTrader 5. The settings have the same names, units and checks as in our strategy builder. It is for MetaTrader 5 only.
Next Steps
Size the trade before you open it: EA risk management. When a stop is refused: MT5 error 10016 (invalid stops). For funded accounts: Prop firm EA rules for MT5. To see what the Trade Manager does and its limits: MT5 Trade Manager.

