The averaging algorithm is now applied to the market

In our previous publications we considered only the stock market from the mathematical point of view. Let's try to transfer the obtained analytical results to market .

math-forex

 

Define the initial conditions

To begin with, let's determine which platform we will use. The most popular of these is MetaTrader 4. It is not only the most popular, but also the most convenient. Its main advantage, which many people simply do not pay attention to, is the ability to play both sides simultaneously. The MT5 platform offers nothing of the sort, despite the fact that it is advertised everywhere. That's why We will work only with the MT4 platform.

Второй момент, на который следует обратить внимание — это, конечно, an asset in our possession. This pair has a spread of about 2 pips, which is quite often floating, i.e. changing during the movement of the exchange rate depending on the total market volume. This pair has a spread of about 2 pips, and quite often this spread is floating, that is, it changes during the movement of the rate, depending on the total market volume. It is also the minimum for all assets, regardless of the broker you work with.

Opening longs

Let's start by looking at trading on the upside. All of our actions should be reflected in the program Excel, so it is necessary to prepare tables for further use. The type of tables in this case should dramatically change, compared to the previous one. The first columns on the left will remain the same, and the subsequent columns will be changed.

Figure 1. Example of a table in Excel.
Figure 1. Example of a table in Excel.

This is caused by the following considerations. Every brokerage firm, when trading in the market Reserves ten times the volume of working transactions. Thus, when opening the deal at the price of, say, 1.2584, no matter in what direction, the real price will be the price ten times higher than the initial one, because that is how much is deducted by the broker to the reserve, and our deposit loses not 1.2584 but 12.584. Therefore, this price is used in further calculations, but not the one that we see on the monitor. This, of course, does not mean that we lose this money. When closing the position, it will return to the deposit, but in the process of trading, this factor should be considered in the calculations. Consequently, it is necessary to change the estimated price to the price of validwhich, to eliminate possible confusion, is marked with the letter Д.

Therefore, in the "header" we add the columns  PND, RpD, P(N+n)D. Accordingly, in cell G2 we put the value =10*B2, in cell H2 also tenfold =10*E2. We are left with only cell K1 with the sign (N+n)D. This cell shows us the average value of our open orders, but when filling in cell K2 only current pricesTherefore, the calculation formula must be transformed as follows (C2*G2+J2*H2)/(C2+J2). In order to return to the price values that we see on the screen, the obtained numerical value must again be converted. This is done in cell L2, where we put the value K2/10. Now we need to deal with cells F2, I2, and J2. These cells contain, respectively n, n, n. These letter values differ in both color and spelling. Why this is done will be shown later.

In cell F2, which is under n, we enter the original formula, but taking into account the current prices. It will look like this: ((A2-2*C2*G2)*(G2-H2))/(G2*H2*D2).

In order to deal with nThe following is an example of how to make some calculations, the necessity of which is not obvious at this stage. Nevertheless, it will be justified later on. By examining the formula  n=((D-2*N*PN)*(PN-Pn))/((PN*Pn)*2), it can be easily seen that the maximum value of n will only be in the case of N=0. But then the formula itself would look like n=((D*(PN-Pn))/((PN*Pn)*2). Indeed, the first parenthesis of the numerator will be maximal only if the volume is zero, hence the result will be maximal. Based on this, cell I2 will contain the following formula (A2*(G2-H2))/(D2*G2*H2).

We are left with only n. The cell J2 below this value does not require any formulas and serves only for rounding the previously obtained results. This is due to the fact that in a number of brokerage firms (almost all) exist limitation on staging volume. If the volume step is 0.1, the program will not allow you to put 0.08 or 1.25. In Excel, such a result may well appear, and if it happens, we will operate with its rounded value.

What to do with "shorts"

The resulting table applies only to the upward movement. When moving down, the table differs by only one sign, based on the fact that when playing down the volume of the order placed is negative.

Therefore, in cell F2 in the first parenthesis of the numerator we will not subtract the product of volume and price, but add it to the value of the deposit. Thus, the total value of free money will decrease, which is what we wanted to achieve. The second parenthesis of the numerator determines only the distance between our average price and the current price, so we leave it unchanged.

Последнее, на что я хотел бы обратить внимание, — это the only indicator we will use all the time. This indicator is called iExposure. To find it, click on Insert → Indicators → Custom → iExposure. We will be interested in only one value of Net lots. It will show the difference between the open orders. For example, we trade 3 lots up and 5 lots down at the same time. The indicator will show the difference of -2 between them.

To be continued...
Previous article cycle

One Comment

  1. Hello!

    Can you please give me a link to EXEL language for FOREX: how to prescribe OHLC and other parameters of trade charts in tables, how to set up DDE, so that the table receives data; an example how to write a simple table indicator, so that I could look not at charts, but in the table ...!

    Regards!

Leave a Reply

Back to top button