**Peter Kaiza:**

No problem in the calculation of the difference between the close and high but have difficulties in summing up the consecutive losses, is there a special function that can perform this in Mql5?

If I understand you question correctly, here's your 'special function' :

double CalcMaxDD(int xx) { double maxdd = 0; for (int i=1; i<=xx; i++) { double diff = high[i]-close[i]; if (diff < 0) maxdd = maxdd + diff; } return (maxdd); }But it's strange though... under what condition(s) will the high price of a candle be higher than its close price?

Does anyone know how to perform the max drawdons in xx candles?

I have an example of symbol prices like below:

Candle

Close

high

Diference

0

1.258

1.265

0.007

1

1.265

1.274

0.009

2

1.274

1.286

0.012

3

1.286

1.3

0.014

4

1.3

1.29

-0.01

5

1.29

1.291

0.001

6

1.286

1.285

-0.001

7

1.285

1.283

-0.002

8

1.283

1.281

-0.002

9

1.281

1.29

0.009

10

1.29

1.3

0.01

This is an uptrend because the instrument increased during that period from i.e from 1.258 to 1.29. So the maximum drawdown is the period or the sum of the candle/candles in series or the candle with the biggest loss ; sums of candles 6, 7 and 8 = -0.05.

so max drawdown is -0.05

How do calculate this max drawdown in mql5?

No problem in the calculation of the difference between the close and high but have difficulties in summing up the consecutive losses, is there a special function that can perform this in Mql5?