ApeX Trading Console · MetaTrader 5

Close all trades on MT5

Getting out of many positions at once is easy to start and hard to get right: which ones, at what number, and what happens to the ones the broker refuses.

To close all trades at once in MetaTrader 5, right-click the Trade tab of the Toolbox and open Bulk Operations. From there you can close every position, only the winning or losing ones, or the ones on a single symbol. It works, but only when you do it by hand, and it cannot pick out one strategy's trades by magic number or wait for the basket to reach a set profit.

Doing more than that needs an Expert Advisor. It can close a group you filter in one press, show you what that group is worth before you press, and watch the floating profit or loss of a basket and close it by itself when it crosses your number.

What MT5 already does on its own

Bulk Operations is a real feature and for many people it is enough. Where it runs short is in three places:

  • No magic number. If two EAs and your own manual trades share an account, there is no way to close just one of them.
  • No threshold. "Profitable positions" means every one above zero, including those a few cents up. There is no "only those above 20 dollars".
  • Nothing is watched. A stop loss and take profit belong to one position. Nothing in the terminal closes a basket when its combined result reaches a number — you have to be there to press it.

How do you close a filtered group in one press?

ApeX Trading Console has a Close tab for this. Two filters at the top decide which trades every button below it works on:

  • Symbol — all symbols, or one.
  • Magic — all trades, one EA's magic number, or Manual for the trades you opened yourself.

Every row shows, live, how many trades it would close, their profit or loss, and their change in percent — so you see what you are about to do before you do it.

Button Closes
Close Profit Trades in profit. Optionally only those above an amount of money or a percentage you pick.
Close Loss Trades at a loss. Optionally only those losing more than an amount or a percentage.
Close BUY · Close SELL Every buy, or every sell.
Close ALL Everything that passes the filters. It sits alone at the bottom, under a line, so it is not the button you hit by mistake.
Pending orders One button per order type — buy and sell limit, stop and stop-limit — plus Cancel ALL Pending. Pending orders the EA holds itself, rather than on the server, are counted and cancelled too.

Money or percent — which percent?

The percentage is the same figure MetaTrader shows in the Change column of the Toolbox: how far price has moved against the size of the position, not a share of your balance. For a group of trades it is the combined price profit divided by the combined value of the positions, so a large lot and a small one are weighted properly instead of their percentages simply being added up.

The money column includes swap; the percentage is price movement only.

What happens when you press it

  1. If the Confirm box is ticked, you are asked first, with the number of trades it will touch. Untick it if you want one press to act at once.
  2. Trades are closed one at a time. If the broker refuses some — a requote in a fast market, for instance — the EA checks what is left and tries those again, up to three rounds in all.
  3. Trades on a market that is closed right now are skipped rather than retried, and counted separately.
  4. A result card tells you how many closed and the profit or loss actually booked — swap and commission included — and, if anything is still open, how many failed so you can try again.

Can MT5 close all trades automatically at a profit target?

Not by itself. In the console, the Conditions button on the Close tab opens a watch list that does it. Each row is one rule, and you can keep up to twenty:

  • Where — one symbol, or all of them.
  • Measure — floating profit or loss in your account currency, or the change in percent described above.
  • Rule — at or above a number, for a profit target; at or below one, for a loss limit.
  • Which trades — all, only winners, only losers, only buys or only sells. The rule measures that group and closes that group, nothing else.
  • After it fires — Once removes the rule after it has closed something. Repeat stays and arms itself again when the condition is no longer met or there are no trades left.

Two examples. "All symbols · profit or loss at or above 150 USD · all trades · Once" takes a whole basket off when it is 150 dollars up, then stops. "XAUUSD · change at or below −1.5% · losing trades · Repeat" cuts the gold trades that are underwater whenever they together fall that far, and keeps watching.

The list is checked twice a second while its switch is on, whichever tab of the panel you have open, and it is saved, so it survives a timeframe change or a restart of MetaTrader. Each row shows a live bar of how close its group is to the number.

From a hotkey or from your phone

The same kinds of close can be bound to keys — close all, buys, sells, winners or losers, or cancel a type of pending order. With the free ApeX Telegram Bridge service installed and the Close permission turned on, Telegram gives you the same grid of buttons on your phone, and a command such as /closeprofit>20 closes only the trades above 20.

Note the difference in reach. Hotkeys and Telegram only ever touch this EA's own trades — hotkeys on the chart's symbol, Telegram across all symbols. The Close tab and the watch list can reach every trade on the account, including manual ones and other EAs', depending on the filters you choose.

What it will not do

  • It is not one single order. Positions are closed one after another, so in a fast market each fills at a slightly different price, and the booked result can differ from the number on screen.
  • The watch list has no magic filter. A rule covers every trade in its symbol and group, whoever opened it. If another EA trades the same symbol, its trades are included.
  • It needs MetaTrader running. The watch list lives in the EA. With the terminal closed, or Algo Trading switched off, nothing is watched and nothing closes.
  • It cannot close what the market will not trade. Over the weekend or outside a symbol's session those trades are skipped and reported, and a gap on the open can take the result past your number.
  • Hedging accounts only. ApeX Trading Console does not support netting accounts.

Questions

How do I close all trades at once in MT5?

Right-click the Trade tab in the Toolbox and choose Bulk Operations. It can close all positions, only the profitable or losing ones, or those on one symbol. For filtering by magic number, a money threshold or an automatic target, you need an Expert Advisor.

Can I close all trades automatically when the total profit reaches a target?

Not with MetaTrader alone. In ApeX Trading Console you add a rule to the Close Conditions watch list — for example all symbols, floating profit at or above 150 in your account currency, all trades — and it closes the basket when the total gets there.

Will it close my manual trades or another EA's trades?

In the Close tab, only if the Magic filter lets them through — set it to one number, or to Manual, to keep the rest out. The watch list has no magic filter, so it includes them. Hotkeys and Telegram never touch trades that are not this EA's.

Is the percentage the same as in MetaTrader?

Yes — it is the Change figure from the Toolbox, price movement against position value. For several trades it is weighted by size rather than added up, and it is not a percentage of your balance.

Why did some trades not close?

Usually because their market was closed at the time, which is reported as skipped; because the broker kept rejecting them after three rounds, which is reported as failed; because a filter or threshold left them out; or because Algo Trading was off.

Where this sits in the console

Closing in groups sits beside the tools that manage a single trade — staged exits, break-even, trailing and OCO. The demo edition runs on demo accounts, which is the right place to set up a watch-list rule and see it close a basket before real money is on the line.