Algorithm of averaging: turning the game into work

Master class "Algebra of financial trading".

Developing a mechanical trading systemFirst it is necessary to set ourselves a goal, to realize what exactly we want to achieve, what manner of play we will be satisfied with. Moreover, both our actions and the result should be very formalized. However, theory is usually limited to lengthy arguments, which are very similar to the predictions of the Delphi oracle, because they can be interpreted both in one direction and in the other.

Read the article in ForTrader.org PDF magazine

math

 

Money Management

All conclusions concerning the direction of the anticipated course movement are based on the oscillators and indicatorsThe averaging of historical data is what they are based on. They are value is questionable, to say the leastbecause the movement of the exchange rate is well within the Markov process, which has practically no procedural memory. That leaves only capital management. The maximum that technical analysis offers us in this part is is the limit of loss to 2%, by displaying stop loss (A. Elder). The primitivism of this postulate, it seems to me, does not even need to be discussed. The only plus is the simplicity of calculations, but even it is performed by traders very rarely, and often not performed at all. Let's try to consider ways of capital management based on the obtained averaging algorithm. Using school algebra, we open the parentheses of the numerator and divide the numerator by the value of the denominator. This is done on the basis of the following considerations. If in the first case we have a formula in the form, convenient for differentiation, then by doing the above actions on it, we simplify it for clarity and get an opportunity to consider it as a function n from Pn. Indeed, within the current iteration, all variables of this formula can be taken as constants, except of course, Pn. This allows us to consider the obtained expression as a functional dependence. Omitting all intermediate steps in the derivation, we obtain the following result.

n = (D-2* N)/ Pn + (2*N- D/ PN)where

D - the deposit we have at our disposal;
PN - the price corresponding to the already open volume;
N - total volume;
Pn - current price;
n - volume that we can safely open ourselves up to.

In the resulting expression we have the function n and the argument Pn. All other values, at the moment, within the framework of this iteration are permanent. But the obtained expression is a hyperbola known to us from the fifth-grade algebra course, which can be quite well represented on a graph, because all constants determine only the shift and expansion of the hyperbola with respect to abscissa and ordinate axes, so they can not be taken into account. Of course, no one suggests plotting the graph after each iteration. It is enough to realize that the result of the game becomes predictable as long as our actions correspond to the obtained hyperbola. Thus, we can conclude that a permanent gain is quite realisticIf we have "saddled" the hyperbola and are not going to deviate from it. However, the branches of the hyperbola go to infinity, hence some restrictions must be introduced. And first of all this applies to total volume of open positions.

Calculate the total volume of open positions

In a previous article (cf. #71 of ForTrader.org magazine - Editor's note) I promised to show a way of determining N. It is not complicated. All you have to do is choose the daily investment horizon and determine the trend direction. If we assume that we are playing up, then the maximum price value will correspond to the zero value of the initial volume. On a certain pullback, i.e. a move downwards, we get the volume that we need to open. This is best demonstrated in program Excel on the example of a real calculation. First, we will transfer the basic formula, and we will take both the deposit and all other variables arbitrarily. It will not be connected in any way with the real market, since we will also take an arbitrary asset. The result should be as follows in Excel. In the first line, we place, respectively

1

where all the alphabetic values are already known, and the new designations are only k и PN+n. k - defaults to 2, since we only use half of the market gift, and PN+n –  the resulting total input mean as a result of the iteration. By placing the "hat" in the table, the formula must also be placed. Under D put an arbitrary figure, which will correspond to the allegedly involved deposit, let's assume 50 000, no matter what dollars, pounds, rubles, escudos, tugriks. Under PN we again put the arbitrary price of the asset, say 8.28. Under N - the volume that is already working. Let it be equal to 10 shares. About kI have already said that it is 2. Under Pn we place the price that is formed at the current moment and is waiting for our actions. Since we are playing up, and the rate is presumably going down, we will place a lower price than the one we had before. Let this price be equal to 8.02. Then in cell F2, located under n, let's put the formula itself, which for Excel will look like this ((A2-2*C2*B2)*(B2-E2))/(D2*B2*E2), and the result in cell F2 will be 98 shares. Of course, the value will be obtained in fractions, but it is impossible to buy less than one share, so Excel is set up so that round the returned value. The same applies to the other values.

The price, for example, is rounded to two decimal places. Of course, rounding can be done manually, but why add work to yourself if you can do it all automatically? We have an empty cell G2, which is located under PN+n. This cell should contain the value of the new average entry, taking into account the purchase of 98 shares at 8.02. The algebraic formula is as follows. It has already been given in a previous article, but let me remind you.

P(N+n) = (N*PN+n*Pn)/(N + n)

And in tabular it will look as (B2*C2+E2*F2)/(C2+F2), the returned value will be 8.04 and it should be transferred to cell B3, since it is the new price of our entry into the market. However, the number of purchased shares will also change and will be the sum of the sum of 10 and 98 shares, which is recorded in the corresponding cell.

2

The iteration is complete, the result is obtained, and now we will base our subsequent calculations on the values already obtained. All these considerations apply to stock market. For market they are suitable only with some changes, which are not fundamental. The basic idea remains the same: price chasing by averaging. The following publications will show methods and ways of playing the foreign exchange market, taking into account the "leverage".

Using the above, we can say that the "game" turns into "work," because the excitement, greed and fear are lost. The trader has only to perform the specified actions.

Leave a Reply

Back to top button