Dear all,
In MT4 we were able to hard set for example a max of 10% equity DD for the optimization
process.
In MT5 they do not have a direct feature for this so I was figuring out how to code it.
Right now I have been using the following code but getting an error.
"Genetic pass 0,506) tested with error " incorrect input parameters" in 0:00:00.000"
Once the INIT PARAMETERS INCORRECT has been triggered the entire optimization directly stops in the first 5 seconds.
Why does the optimization not continue? Is there a way so I can set as an input the max drawdown I would like to realize?
Help is greatly
appreciated <3
The manual page on TesterStatistics mentions that the results are only available during OnTester() or OnDeinit(). In other words, once the
test is running or has completed. You are using it during OnInit(), but at that time does it not yet have any value. So your handle_dd parameter
has an undefined value.
https://www.mql5.com/en/docs/common/testerstatistics

- www.mql5.com
The manual page on TesterStatistics mentions that the results are only available during OnTester() or OnDeinit(). In other words, once the
test is running or has completed. You are using it during OnInit(), but at that time does it not yet have any value. So your handle_dd parameter
has an undefined value.
https://www.mql5.com/en/docs/common/testerstatistics
Thanks for the insight here!
Do you/anyone know if what I am looking for is possible? With this
function or maybe another one?
Stay safe!

- www.mql5.com
WindmillMQL:
The manual page on TesterStatistics mentions that the results are only available during OnTester() or OnDeinit(). In other words, once
the test is running or has completed. You are using it during OnInit(), but at that time does it not yet have any value. So your handle_dd
parameter has an undefined value.
https://www.mql5.com/en/docs/common/testerstatistics
Thanks for the insight here!
Do you/anyone know if what I am looking for is possible? With this function
or maybe another one?
Stay safe!
I think that you need to think again about when you need the drawdown data. You are now using it in OnInit(), which means before you even started any testing or trading. Do you think that you already have drawdown before the very first trade?
If you read the documentation page which I provided you can see what standard functions you'll need to include in your code if you want to use it during or after a backtest or optimization.
If you want to use it during live trading or paper trading, you may have to write your own function to calculate drawdown while trading is
ongoing.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Dear all,
In MT4 we were able to hard set for example a max of 10% equity DD for the optimization process.
In MT5 they do not have a direct feature for this so I was figuring out how to code it.
Right now I have been using the following code but getting an error.
"Genetic pass 0,506) tested with error " incorrect input parameters" in 0:00:00.000"
Once the INIT PARAMETERS INCORRECT has been triggered the entire optimization directly stops in the first 5 seconds.
Why does the optimization not continue? Is there a way so I can set as an input the max drawdown I would like to realize?
Help is greatly appreciated <3