Closing all open trades if all one symbol and one trade direction – script MetaTrader 4

Closing all open trades if all one symbol and one trade direction - script for MetaTrader 4
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

Open Trade – script MetaTrader 5

Open Trade - script for MetaTrader 5
This function executes the primary logic for initiating a trade. Computes the opening price, take-profit levels, and stop-loss based on symbol information and user-provided parameters. Prepares a trade request (MqlTradeRequest) with essential details such as symbol, volume, order type, deviation, comment, magic number, etc. Invokes the OrderSend function to dispatch the trade request and obtain