Lot calculation by Vince - page 5

 
MaxZ:
Either I got it wrong again, or the results of running the EA in the tester for the first and second time are identical. The only "but": the second time, the Expert Advisor still calculates the optimal parameter f...


That's right - this parameter is used to calculate the volume of the lot in the bidding afterwards. The method is geometric mean. See page 31 of the book. 31 of the book and run it in any board and try to calculate it.

I myself am now following your advice from the first page and break down the product to the roots, so as to avoid overfilling.

 

Then why run the test again? If we can find the most unprofitable trade in the deinit() function, also the number of trades, instead of entering these parameters manually? That is, calculate the optimal f after the first test.

Or the tester does not allow to do it?

 
MaxZ:

Then why run the test again? If we can find the most unprofitable trade in the deinit() function, also the number of trades, instead of entering these parameters manually? That is, calculate the optimum f after the first test.

Or does the tester not allow you to do so?


Theoretically it allows, but ... It can be implemented in different ways. But it would be a pure fitting. You have to calculate without knowing the future
 
Vinin:

Theoretically it allows, but ... There are different ways to implement it. But it would be a pure fit. We need a calculation without knowing the future.


The point is that it's R.Vince - see the trailer posts above pp. 31-32. There's no way around it - just take a representative sample for any case and that's it, and then come up with a rounded value of max loss upwards, not even rounded, but increased by a factor of 1.5 and that's it... Everything is fine here. Deals - also under 500 and that's it... I can already calculate optimal f with necessary tolerances to the right/left.

The question is different - how to avoid TWR variable overflow?


 
Roman.:


The point is that this is R. Vince - see the trailer posts above pp. 31-32. There is no way around it - just take a representative sample for any case, and then dance from there, and round up the values of max loss, not even round it up, but 1.5 times as much and that's it... Everything is normal here.

The question is different - how do you avoid over-representing the TWR variable?



Limit the depth of calculations
 
Vinin:

Limit the depth of calculations

How?
 
Roman.:

How's that?

I just mean the number of trades being analysed. Real or virtual.
 

Something began to emerge - as absolute values of variables are not important, but only their comparison on more, less at a certain value of f, Iadded the third degree root of TWRon the recommendation of MaxZ: the first page, in this block - it works fine, without overflow:

for (f = 0.01; f<=1.0; f=f+0.01)//цикл перебора переменной f для поиска оптимального ее значения,при котором TWR-максимально
     {  
          
          for ( orderIndex = 1;orderIndex<Qnt; orderIndex++) //при заданной f проходим по всем закрытым ордерам
            {                                                // и считаем относительный конечный капитал (TWR)
             TWR = MathPow(TWR*(1+f*(-Mas_Outcome_of_transactions[orderIndex]/(D))),0.33); // TWR - это произведение всех HPR                    
            }
          if (TWR>TWR_Rez) {
              TWR_Rez = TWR;
              G=MathPow (TWR_Rez, 0.001988); // 1/503 сделки по данной торговой системе, как в книжке: в степени 1/N 
              Print(" TWR = ",TWR_Rez," G = ",G, " при f = ", f);} // если текущий TWR > результирующего, 
              else break;    // то результирующий делаем равным текущему, иначе переходим на след итерацию цикла по f                                  
      }      
             
   Print("Закрытых позиций = ", Qnt, " Нетто Профит/лосс = ", SUMM, " У последней ",Qnt, " закрытой позы профит/лосс = ", 
        Mas_Outcome_of_transactions[Qnt]);     
  

In the log:

 
Vinin:

I'm only talking about the number of trades analyzed. Real or virtual


I do all the calculations in the tester using opening prices, trades from 2002 to date 2011 - 503, highest loss trades = -628.

The results are above. I am testing on other Expert Advisor variants now.

Here is the text of the approach to solving this problem from the source code - p. 31.

We have seen that the best trading system is the system with the highest geometric mean. To calculate the geometric mean we need to know f. So, let's describe our actions step by step.

1. Take the history of transactions in the given market system.

2. Find the optimal f by looking at different values of f from 0 to 1. The optimal f corresponds to the highest value of TWR.

3. Once you find f, take the root of degree N TWR (N is the total number of trades). This is your geometric mean for this market system. Now you can use the obtained geometric mean to compare this system with others. The f-value will tell you how many contracts to trade in this market system. Once f is found, it can be converted into the money equivalent by dividing the biggest loss by the negative optimal/. For example, if the largest loss is equal to $100, and optimal f = 0.25, then -$100 / -0.25 = $400. In other words, you should bet 1 unit for every $400 account. For simplicity you can calculate everything on a unit basis (for example one $5 chip or one futures contract, or 100 shares). The number of dollars to allocate to each unit can be calculated by dividing your largest loss by the negative optimal f. The optimalf is the result of balancing the system's profitability (based on 1 unit) and its risk (based on 1 unit). Many people think that the optimal fixed fraction is the percentage of the account that is allocated to

 
Roman.:

Something began to emerge - as absolute values of variables are not important, but only their comparison on more, less at a certain value of f, Iadded the third degree root of TWRon the recommendation of MaxZ: the first page, in this block - it works fine, without overflow:

In the log:

That's not exactly the kind of recommendation I was making. That is more your approach. The important thing is that it also turns out to be the right one.
Reason: