Sometimes you need to quickly stop trading on all open orders, but manually doing this can be problematic, especially if the market has a large group of orders, and you need to close as quickly as possible without clicks manually and loss of profit due to price movement. This task will help to cope with a set of scripts for the terminal Meta Trader 4: DaVinci Close all orders.
This set consists of three scripts to close market orders on user-specific settings, such as choosing the direction of the closed transaction, accounting for the magic number, or the symbol.
An additional option is to remove all pending orders.
List of three scripts:
- Close all trading orders – closing all orders in the terminal without taking into account their profit/loss, as well as the possibility of removing pending orders.
- Close all profit orders – closing all profitable orders, the income of each of which is above 0, taking into account the commission and swap.
- Close all loss orders – closing all loss orders, the loss of each of which is below 0, taking into account the commission and swap.
Script Settings:
Order Magic Number | Magic number orders that you want to close. At -1, orders with any magic are closed. |
Choose Order Type | Choosing the type of warrant. Market Order – market order, Pending Order – deferred order or both types at once (removal of deletion is available only in the script Close all trading orders). |
Choose Order Direction | Choosing the direction of the closed order: to buy, sell or both directions at once. |
Closing Symbol | Choosing a trading pair: current or all open pairs. |
An example of how the script works:
As we can see in the screenshot, there are now 6 orders in the market, and we want to close all loss-making pairs of EURAUD, i.e. Two warrants.
To do this, manually transfer the script Close all loss orders to the open schedule EURAUD, confirm in the settings that we want to close orders with any magic number (i.e. take into account all the magic), also take into account any direction of transactions, but the symbol is exhibited current Symbol, i.e.. Current.
As a result, we closed 2 orders, and there are 4 remaining orders left in the market.
If now we want to close all the remaining loss-making orders, we just throw the same script on any currency pair and do not change the settings click OK.
There will be one order left in the market:
After the script completes the work, he will give information in the log about how many orders he closed, what total lot was in these orders, as well as the total profit, or loss.
Two other scripts work the same way.
[download url=”http://www.davinci-fx.com/wp-content/uploads/2021/01/Close-all-orders-script.rar” title=”Download for free”]