Close All Trades is a MetaTrader 4 Expert Advisor that automatically closes trades based on customizable criteria. Users can specify whether to close buy or sell orders, filter by profit or loss, magic number, or comment. It offers options for slippage, retry attempts, and sorting orders before closing. This tool simplifies trade management, ensuring efficient and customizable trade closure.
Inputs
OnlyCurrentSymbol : If set to true, the EA will only close trades for the instrument on the chart where the EA is attached. If false, it will close trades for all instruments.
OrderTypeFilter : Specifies the type of orders to close:
ALL_ORDERS: Close all orders.
ONLY_BUY: Close only buy orders.
ONLY_SELL: Close only sell orders.
OnlyInProfit : If true, the EA will only close trades that are currently in profit.
OnlyInLoss : If true, the EA will only close trades that are currently in loss.
OnlyMagicNumber : If true, the EA will only close trades with a specific magic number.
MagicNumber : The magic number used to filter trades if OnlyMagicNumber is set to true.
OnlyWithComment : If true, the EA will only close trades with a specific comment.
MatchingComment : The comment used to filter trades if OnlyWithComment is set to true.
Slippage : The maximum acceptable slippage in points when closing trades.
Delay : The delay in milliseconds between closing attempts for each trade.
Retries : The number of times the EA will attempt to close each trade if the initial attempt fails.
Sort : Specifies how orders should be sorted before closing:
SORT_ORDERS_NO: No sorting.
SORT_ORDERS_ABS_PROFIT_ASC: Sort by smaller profit/loss first.
SORT_ORDERS_ABS_PROFIT_DESC: Sort by larger profit/loss first.
SORT_ORDERS_PROFIT_ASC: Sort from biggest loss to biggest profit.
SORT_ORDERS_PROFIT_DESC: Sort from biggest profit to biggest loss.