fbpx

We recommend:

  1. Home
  2. Scripts
  3. Close all orders – closing trading and deleting deferred orders

Close all orders – closing trading and deleting deferred orders

Scripts for closing deals and deleting pending orders

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:

  1. 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.
  2. Close all profit orders – closing all profitable orders, the income of each of which is above 0, taking into account the commission and swap.
  3. 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 NumberMagic number orders that you want to close. At -1, orders with any magic are closed.
Choose Order TypeChoosing 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 DirectionChoosing the direction of the closed order: to buy, sell or both directions at once.
Closing SymbolChoosing 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu