Бесплатный курс "Управляй вероятностями"

Algorithms for extracting trades automatically

Before loading a report, read this information carefully.

1. General overview of loading a brokerage report

Open trades at the beginning of the period + Transactions from the brokerage report for the period = TRADES + open trades at the end of the period


Open trades this is the table “Open positions”, from which positions open at the beginning of the loaded report should be drawn before the report is loaded.



It is VERY IMPORTANT to fill this in correctly, because open positions are used when automatically extracting trades.





You have a brokerage report for March 1.

At the beginning of the date of March 1 you have an RTS position open – with 10 contracts in long.


In the report:


- 10 longs are closed

- 5 shorts are opened

- 5 shorts are closed.


If everything in the table of open trades is correct, then after loading the report we get two trades:


- RTS long 10

- RTS short 5


If you have forgotten to fill in the open trade and add it to the table of open trades, then after loading the report we get:



RTS short 5


and an open position in short 10


which does not correspond to reality, but is also not a mistake, because you have precisely fed this data to the algorithm for setting up trades.



Be careful about what you are doing! 



Open trades + transactions from the brokerage report = TRADES



The transactions which have not gone into the trades are open positions at the end of the period.



If trades have been loaded in an incorrectly, delete them from the period loaded, manually list the open positions in the “Open position” table, and load them again.


 The reports from certain brokerages contain information on open positions. Compare the information from the report with the information in the table of open trades before loading.


2. Algorithms for extracting trades

There are currently two algorithms for setting up trades.*


First algorithm

A table of transactions is created from the brokerage report, where trades are selected sequentially (one after another) and are paired with trades with the opposite direction.

Next, the smallest amount is chosen from a transaction pair, a trade is established with this amount and the transactions are deleted from the table.

Thus, the trades are set up exactly as the transactions in the brokerage report show.


The first method is the most accurate and the least intuitive, because it often happens that an order is carried out for a certain amount of time, in several chunks, and consequently one trade can be split into several trades. This does not change the total result but at the same time does not correspond to what we think is one trade.


Second algorithm

First, the transactions in the table of transactions are grouped within the set timeframe and with one direction, which is intended to gather the initial order together.

The amount within the transactions is added up and the price of the combined transactions is averaged proportionally to the amount in each transaction.

The first algorithm is then applied to the resulting table.

With the second method, we aim to specify the initial size of the trade as accurately as possible.

For the second algorithm, it is best to choose the most appropriate time, so that your transactions will be combined as accurately as possible.


By default, the system uses the second algorithm and the time for combining trades is 10 seconds, which is suitable for most reports.

The methods and the settings for these algorithms can be found in the account settings.


* These algorithms do not apply to reports from MT4 for Forex, where the trades in the report are already set up.