This free product closes all trades based on specific properties such as magic, profit, type, etc.
It is based on one of the scripts found in one of my Code Base articles, CloseAll.
A collection of scripts for closing various types of orders.
- closeall_comment - closes all orders based on a specific comment
- closeall_loss - closes all orders with profit/loss exceeding a specific loss threshold value
- closeall_profit - closes all orders with profit/loss exceeding a specific profit threshold value
- closeall_magic - closes all orders by order magic number
- closeall_market - closes all market orders
- closeall_pending - closes all pending orders
- closeall_complete - contains all the features of six scripts + option for closing position at a symbol
When a parameter is ignored, the condition involving that parameter would automatically evaluate to true (as if it is not present on the script).
Parameters of string type (order comment and order symbol) are ignored by the script when their value is either NULL or empty string.
Parameters of real type (profit, loss, and magic) are ignored by the script when their value is -1.
Using Exact Match
In order to get an exact match, the parameter exact match should be equal to true. When searching for an exact match, the script respects ignored parameters.
When exact match=false, however, the script would close an order if at least one criterion is satisfied. This means that the script should not have ignored parameters. Otherwise, all orders would evaluate to true (closing the order).