For the consideration of professionals.

 

There is talk of maximum drawdown. It was suggested by someone that the tester was not measuring it correctly. I decided to check it. I wrote a code and added it to my Expert Advisor and ran it in the test mode. The results coincided with the tester. The code is provided below.

Please reassess the correctness of the algorithm and would like to know whether the max drawdown can be calculated without calculating the maxima and minima.

double MaxDrawDown;
int deinit() {
 Print("MaxDrawDown=",MaxDrawDown);
   return (0);
} 

start(){ 
  static double MaxEquity;
  static double MinEquity;
         double DrawDown;
  static bool flag;
 
  if(!flag)
    {
     MaxEquity=AccountEquity();
     MinEquity=AccountEquity();
     flag = true;
    } 
  if(AccountEquity()>MaxEquity) 
    {MaxEquity=AccountEquity();MinEquity=AccountEquity();}
  
  if(AccountEquity()<MinEquity) 
    {MinEquity=AccountEquity();}
  
  DrawDown=MaxEquity-MinEquity;
  
  if(DrawDown>MaxDrawDown ) 
    {MaxDrawDown=DrawDown;}
// ............остальной код советника
 

What do you mean by not calculating? During the run you had both maximum and minimum...

The problem is that you won't know the drawdown in this way online - you will have to calculate it.

 
FAQ:

What do you mean by not calculating? During the run you had both maximum and minimum...

The problem is that you won't know the drawdown in this way online - you will have to calculate it.

The question about highs and lows arose in connection with the post OnGoing, who wondered what the highs and lows were for. So I thought maybe there is some other way to calculate max drawdown, without the highs and lows? I mean, is the calculation correct in principle? And what problems will arise online? Can you explain why this method will not work? Maybe you mean that there will be problems if there is more than one Expert Advisor and we cannot specify this code for each of them. If that is what you mean, I understand what you mean. Or something else?

 
Because from the history (orders) you can only reconstruct the balance curve, but the equity curve you will have to synthesize based on the number of open orders at each moment, the margin on each order (currency) and the highs / lows of the price.
 
FAQ:
Because you will only be able to reconstruct the balance curve by history (orders) but you will have to synthesize the equity curve based on the number of open orders at each moment, the amount of margin for each order (currency) and the highs and lows of the price.

If we have just launched the Expert Advisor and there is no history, can't we calculate the maximum and minimum of equity storing it in global variables and calculate the current and maximum drawdown at the moment? Or did I misunderstand something? Or maybe you are considering a situation where there is already some history. And you want to calculate the maximal drawdown taking into account the order history, by running the script? Then it is clear. But if we have just started working and there is no history or there is, but we want to calculate the drawdown from the moment of launching the Expert Advisor with this code, isn't there anything that can prevent us from doing that?

 
khorosh:

If we have just launched the Expert Advisor and there is no history, can't we calculate the maximum and minimum of equity storing it in global variables and calculate the current and maximum drawdown at the moment? Or did I misunderstand something? Or maybe you are considering a situation where there is already some history. And you want to calculate the maximal drawdown taking into account the order history, by running the script? Then it is clear. But if we have just started working and there is no history or there is, but we want to calculate the drawdown from the moment of launching the Expert Advisor with this code, isn't there anything that can prevent us from doing so?


It would be easier to read the Equity Indicator readings from the Surgeon, rather than store something in some variables.
 
Reshetov:
It is easier to read the Surgeon's Equity Indicator than to store something in some variables.
I agree, the code was intended to run in the tester, I just wondered if I was counting correctly in principle, because OnGoing gave me doubts.
 
Integer:

Don't sweat it, he's made a lot of off-topic mockery here, and not even on-topic, but completely off-topic.
Thanks for the encouragement, because I was beginning to have doubts that I had misunderstood.
 
khorosh:

There is talk of maximum drawdown. It was suggested by someone that the tester is not measuring it correctly.

The tester measures the maximal drawdown of equity correctly but it does not take into account the balance state at this moment, which makes this measurement nonsense.

In other words, if the open order rises and then falls by 100 pips, the tester will show a 100 pips drawdown of equity while the real drawdown that logically determines the strategy risk is equal to zero. It is clear that such calculations are useless for assessing strategy risks.

 
khorosh:
Thanks for the encouragement, because I was beginning to have doubts that I was misunderstanding.


In general, max drawdown is not the difference between max equity and min equity. At the beginning, Max Equity= Equity, Min Equity= Equity, Drawdown=0. If Equity>MaxEquity, then we consider the drawdown as MaxEquity-MinEquity, if the obtained value is higher than the drawdown calculated earlier, we memorize the larger value and reset the minimum at once - MinEquity=MaxEquity and memorize the new maximum MaxEquity=Equity.
 

The red lines show the drawdowns, you need to find the maximum.

Reason: