For the consideration of professionals. - page 3

 
khorosh:
The purpose of your post is to show how to correctly count the drawdown? Thanks for the EA. It only seems to me that your code, if included in a real EA, will determine the drawdown for one or more open trades from the moment of opening until the closing of these trades, but it will not search for the maximal drawdown of the whole time the EA is working. Or did I get it wrong? Can you criticize my code? Does it correctly perform its task of finding the maximal drawdown?


This (my) code exactly saves the maximum drawdown for the entire time of work of the Expert Advisor, i.e., it does not reset max and min variables when closing a trade(s), when equity equals balance and there is no min for the entire time.

I wrote it purely as an example and to keep it simple - as a comparison with a tester.

About your code it's not clear why to use it here:

  if(AccountEquity()>MaxEquity) 
    {MaxEquity=AccountEquity();MinEquity=AccountEquity();}

MinEquity is reset.

MinEquity=AccountEquity();

If in a situation where AccountEquity() > MaxEquity there is no possibility to close or open an order (or orders) for various reasons, let alone reset MinEquity=AccountEquity();

Generally, the same thing can be programmed in different ways in different ways, the main thing is the right algorithm.

If you want to insert the variable into a real EA, it is better to write the variables in files (with check).

In my opinion, the maximal drawdown and relative drawdown are not taken into account in the tester; I gave an example link earlier.

 
serferrer:


This (my) code exactly saves the maximum drawdown for the entire duration of the EA, i.e. it does not reset max and min variables when closing a trade(s), when equity equals balance and no min for the entire time.

I wrote it purely as an example and to keep it simple - as a comparison with a tester.

About your code it's not clear why to use it here:

MinEquity is reset.

If in a situation where AccountEquity() > MaxEquity there is no possibility to close or open an order (or orders) for various reasons, let alone reset MinEquity=AccountEquity();

Generally, the same thing can be programmed in different ways in different ways, the main thing is the right algorithm.

If you want to insert the variable into a real EA, it is better to write the variables in files (with check).

In my opinion, the tester wrongly takes into account the maximal drawdown and relative drawdown, the link to the example I gave earlier.

MinEquity is reset the moment a new maximum is refreshed, which means that the previous minimum is passed and after the new maximum is formed it is necessary to find a new low that can give the drawdown higher than the drawdown found earlier relatively to the new maximum. Note that we should calculate the drawdown relative to the last maximum by the minimum formed after this maximum and select the maximal one among them. See confirmation in Integer's posts, who also thinks this is correct. I think this is the reason you have a discrepancy with the tester.

 
Serferrer, your variant will show the wrong drawdown, in case of a succession of losing orders. You can get 10 losing orders in a row with a loss of 100 each, and then you will lose 1000 and the maximum drawdown will only be 100, which is wrong.
 
Integer:
Serferrer, your variant will show incorrect drawdown in case of a series of losing orders. You can get 10 losing orders in a row with 100 losses each and drain 1000, while the max drawdown will be only 100, which is wrong.


I repeat - I wrote it purely as an example and simpler (for clarity) - as a comparison with the tester.

And it is in no way final.

If you make the final code, you need to add many other features to it.

 
serferrer:


I repeat - I wrote it purely as an example and for simplicity - as a comparison with the tester.

And it is in no way final.

If you make the final code, you need to add many other features to it.


For an example of what and comparison with what in the tester? Your code does not calculate account drawdown and cannot be used as an example for calculating account drawdown and therefore cannot be used to compare account drawdown calculations in the tester.
 
khorosh:

MinEquity is reset the moment a new maximum is refreshed, which means that the previous minimum is passed and after the new maximum is formed it is necessary to find a new low that can give the drawdown higher than the drawdown found earlier relatively to the new maximum . Note that we should calculate the drawdown relative to the last maximum by the minimum formed after this maximum and select the maximal one among them. See confirmation in Integer's posts, who also thinks this is correct. I think this is the reason you have a discrepancy with the tester.


This is your opinion, I understand it and I myself think it is not correct and the drawdown should be calculated based on open order(s) price rather than the equity maximum, I repeat:

If for example in a situation where AccountEquity()>MaxEquity there is no possibility to close or open an order(s), for various reasons.

 
Integer:

For an example of what and a comparison to what in the tester? Your code does not calculate the account drawdown, and therefore cannot be used as an example for calculating the account drawdown and therefore cannot be used for comparing account drawdown calculations in the tester.


For comparison and a clear example, to make it clear even to non-programmers that the tester doesn't calculate drawdown correctly.

Absolute Drawdown - drawdown of the initial balance showing how much the balance decreased relatively to the initial value;
Maximal Drawdown - the drawdown showing the maximal drawdown fixed in money terms (the difference between the last maximum and the current minimum); can exceed the Absolute Drawdown, showing the amount of possible loss even if the trade is positive;
Relative Drawdown - relative drawdown, shows the maximum drawdown percentage relative to the initial deposit;

http://www.onix-trade.net/forum/index.php?showtopic=82146&st=0&p=342915&#entry342915

Integer:

Do you agree that in my example - Maximum drawdown 1013.00 (50.85%) Relative drawdown 50.85% (1013.00) and this is correct?

 
serferrer:


For comparison and illustrative example, even non-programmers understand that the tester does not calculate correctly.

Absolute Drawdown - drawdown of the initial balance, which shows how much the balance has decreased relatively to the initial value;
Maximal Drawdown - the drawdown showing the maximal drawdown fixed in money terms (the difference between the last maximum and the current minimum); can exceed the Absolute Drawdown, showing the amount of possible loss even if the trade is positive;
Relative Drawdown - relative drawdown, shows the maximum drawdown percentage relative to the initial deposit;

http://www.onix-trade.net/forum/index.php?showtopic=82146&st=0&p=342915&#entry342915

Integer:

Do you agree that in my example - Maximum drawdown 1013.00 (50.85%) Relative drawdown 50.85% (1013.00) and this is correct?


No, I don't agree with you at all or in anything.
 
khorosh:

Explain where you found such a parameter as minimum drawdown, in which report. I believe that the maximum equity drop found during the test run can be repeated in real trading, so I think it is correct to count it from the maximum.

Sorry about the minimum drawdown - my mistake. Fixed the post. And why it does not make sense to calculate the maximum drawdown of equity on an open order in free flight?
 
Reshetov:

Well, if you don't need it or don't understand what it's for, why join the conversation and even impose your opinion?
Read carefully. I asked why others need it, not myself. I am not imposing my opinion, I just explained the logic.
Reason: