Linking orders - based and statistical coverage
Linking orders - based and statistical coverage
To be able to handle their commercial or technical algorithms (coding for beginners) safely, it is first necessary to know with certainty which commercial action which algorithm belongs. I have highlighted the phrase "with certainty" intentionally because if there is even the slightest chance of failure, the failure of management positions will eventually be inevitable. Instead, it will cause the complete destruction of statistics, and ultimately lead to the disorder and the complete failure of the idea of managing different algorithms in the single account.
Reliable separation of commercial actions is based on two main possibilities:
The ability to attach or " bind " two seals commercial orders to always be able to determine which of these two commands is the command that opens the (virtual) individual position and what that closes this position;
The algorithm analyzes the occasion of his orders must be completely bound deterministic unified for all program modules.(learn to program)
Later we'll talk in more detail on the second requirement regarding determinism algorithm, now let's see the first point.
The order is an instruction commercial sale or purchase. The order represents a defined entity that includes many other information "fields" apart from the main information (unique identifier or order number, price and conditions required opening).
One of these fields in MetaTrader 5 is called " Order Magic ". It is a special field that is used for a commercial robot or Expert Advisor (EA) to check this order with their unique personal number is also called the "magic number" of EA. This field is not used for manual trading. However, it is very important for commercial algorithms because when the algorithm analyzes its value, you can always see if this order has been placed by him or by another algorithm.
Suppose we need to open a classic long position and then close it after a while. For that we need to place two orders: the first order open this position and the second order will close it after a while.(how to learn programming)
Fig. 2. Orders that form a historical net position
And what will happen if we put the unique number of the first order in the "Order Magic" field of the second order at the time of shipment to market?
Later we can read this field, and if its value matches the number of the first order, we can safely say that the second order is related to the first and represents the opposite order the closure of the position.
Well, that could reflect this linked schematically:
Fig. 3. Linking orders
Relatively speaking, these orders can be called as linked since the second order contains the link to the first. The first command opens the new position can be called the order initiating or opening . The second command will call the order closing .
The link between these two orders will call the position . So there is no confusion with the concept "position" in MetaTrader 5, we will call these positions linked bidirectional coverage (hedging) or HedgeTerminal positions . Positions in the MetaTrader 5 will call the netto positions or top positions in MetaTrader 5.
Clearly, the number and address HedgeTerminal positions can be any, unlike the classical positions. But if there is any command executed which does not concern any other order? This order can be represented as an active two-way position. True, if in the future we place an order opposite direction containing the reference to this order, then it will be the order which closes the first order. These commands will be linked to form a bidirectional position closed , because the volume of two orders coincide and its direction is opposite.(best programming language to learn)
Well, let's give a definition to what HedgeTerminal regarded as a position:
If a command executed does not refer any other order, HedgeTerminal considers this order as an active two-way position .
If an executed command relates other executed command, these two commands together form a bond, and from the viewpoint of HedgeTerminal regarded as a bidirectional position historical or closed .
Actually, the linked orders in HedgeTerminal is more complex because each order generates at least one operation, and conditions of the stock trading can be a lot of these operations. In total, the trading process can be reflected as follows: the trader sent through the MetaTrader 5 the order to open a new position. Bag running this command by one or more operations.(coding for beginners)
As orders, operations contain fields for additional information. One of these fields contains the identifier of the order based on which the operation has been executed. By reading this field, you can find out which order belongs to the operation. But the reverse is not true. The order "does not know" what operations you own. It happens that at the time of placing the order yet which operations will run is known, and if will be executed or not.