Guarda come scaricare robot di trading gratuitamente
Ci trovi su Twitter!
Unisciti alla nostra fan page
Script interessante?
Pubblica il link!
lasciare che altri lo valutino
Ti è piaciuto lo script? Provalo nel Terminale MetaTrader 5
Sistemi Esperti

Close All Positions Panel - sistema esperto per MetaTrader 5

Cristhian Alexander Gaibor Cuasquer
Cristhian Alexander Gaibor Cuasquer
  • Founder & Systems Engineer al  Xander Pro
  • Ecuador
  • 7095
4.9 (31)
Trader e membro di MQL5 dal 2017.
Visualizzazioni:
245
Pubblicato:
Freelance MQL5 Hai bisogno di un robot o indicatore basato su questo codice? Ordinalo su Freelance Vai a Freelance

Seven buttons on the chart to close positions on Gold (XAUUSD), EURUSD or any symbol in one click: close all, close buys, close sells, close winners, close losers, close only the chart symbol, and delete pending orders. It works on manual trades and on positions opened by any other EA.

A magic number filter decides what the panel touches. 0 means everything on the account, manual trades included, any other value limits it to that EA. A scope switch limits the panel to the chart symbol or opens it to all symbols, and a line under the buttons shows how many positions it would close and their floating result.

Before each close an optional confirmation box asks Yes or No, so a misclick does not wipe the account. The positions are closed one by one with market orders, so in a fast market each one fills at its own price. The panel never opens a trade.

Close All Positions Panel expert advisor on a MetaTrader 5 chart with seven close buttons

Settings

Close / Exit

  • Delete pending orders with Close All (true): the Close All button also removes the pending orders that pass the filters.
  • Ask for confirmation before closing (true): a Yes or No box before every close button. Delete Pending works without it.

Filters

  • Positions the panel works on (All symbols): or Chart symbol only. The Close symbol button always works on the chart symbol.
  • Magic number (0): 0 means all positions, manual trades included. Any other number limits every button to that magic.

Panel

  • Panel corner, Horizontal offset (12 px), Vertical offset (28 px).
  • Button width (134 px), Button height (24 px), Font size (9).
  • Colors for the text, the neutral, buy, sell and Close All buttons, and the info line.

Expert settings

  • Max slippage (30 points).
  • Print every action to the Experts log (true): each closed ticket with its symbol and result.
  • Object prefix (XP_CAP_): only objects with this prefix are created and removed.

What it needs

  • MetaTrader 5 with Algo Trading enabled. Hedging and netting accounts.
  • It is an expert advisor, so it takes the EA slot of the chart. If another EA runs on that chart, open a second chart of any symbol and attach the panel there. With All symbols it manages the whole account from that chart.
  • Winners and losers are decided by profit plus swap. Commission is not included in that check.

Make it yours

Keep it on a spare chart next to a grid or martingale EA on XAUUSD, EURUSD, GBPUSD, US30, NAS100 or BTCUSD, set its magic number in the filter, and you have an emergency exit for that basket alone without touching your manual trades. Pair it with my Basket Pair Closer, which closes the best winner with the worst loser automatically, and use this panel when you want to decide by hand. If you build your own EA, the close loop is a short function that walks the positions from the end and can be copied as it is.

About this code

Open source. Use it as it is, adapt it, build your own version on top of it.

New versions and new tools are announced first on my MQL5 channel: https://www.mql5.com/en/channels/xander

Questions, suggestions and your own backtests are welcome in the Xander Lab group: https://www.mql5.com/en/messages/02eec85e4364dd01

More tools on my profile: https://www.mql5.com/en/users/09151993a

Provided as is, use at your own risk.

Related

Changelog

  • v1.0 - 2026-10-25 - Initial release
Auto Fibo Extended Auto Fibo Extended

Auto Fibo Extended is a MetaTrader 5 indicator designed to automatically identify significant swing highs and swing lows and draw Fibonacci Retracement and Extension levels directly on the chart.

Risk Lot Sizing Library - four risk bases, tick-value scaling, margin cap, daily limit Risk Lot Sizing Library - four risk bases, tick-value scaling, margin cap, daily limit

A stop distance in points is not money until the tick size and tick value make it one. This library turns four risk bases into a lot size, floors it to the volume step, caps it against free margin and tracks a daily loss limit. Two MQL5 headers, no DLL.

Session Range Breakout Session Range Breakout

Draws the high and low of a chosen time window and alerts on the first break on each side. The levels are also available through iCustom.

Trade Manager Utility Trade Manager Utility

Manages positions that are already open: it adds a missing SL/TP, moves the stop to break even, trails it, caps the position count and applies daily equity limits. It never opens trades.