Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 4 Script | Closing all open trades if all one symbol and one trade direction

MetaTrader Experts, Indicators, Scripts and Libraries

All open trades must be of same symbol and type, e.g. all GBPUSD and all BUY.

This script will close out your position using one large trade to hedge your position

then using CloseBy() function to close all trades against the one large trade until all

trades are closed. There can be a maximum of 500 open trades.

47759