Error 565 seems to be undocumented, and only one other forum thread mentions it (but without solution): open error [2] & error code 565 on EA optimization
What build of MetaTrader 5 are you using now after the update and what build did you have before?
![open error [2] & error code 565 on EA optimization open error [2] & error code 565 on EA optimization](https://c.mql5.com/36/59/open-error-2-error-code-565-on.jpg)
- 2020.12.19
- www.mql5.com
Do you not keep backups? You should! Its a good practice to keep backups.
Thanks to Andrey Khatimlianskii, you can download previous builds here — https://drive.google.com/drive/folders/1YSUVehcElTpLxCLPMsdlDfFu4Y61yrccSorry, I accidentally deleted this post - copied below
adicahyanto #:
an update to this problem so far: problem seems to be mitigated.
1. downgrading MT5 build version did no help.
2. the problem seem to be from the windows just as mentioned on discussion here: https://www.mql5.com/de/forum/367097
mentioned on windows system error code documentation are as follow:
ERROR_TOO_MANY_THREADS
565 (0x235)
Indicates a process has too many threads to perform the requested action. For example, assignment of a primary token may only be performed when a process has zero or one threads.
source : https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--500-999-
3. what i've done so far, i downgraded my windows 10 to version : 21H2 build 19044, (previously i'm on 22H2)
installed with MT5 build 3504, running optimization on EA & Indicator test code above shown no error.
so what i suspected to be the cause of this problem would be the last quality update of the windows 10 which unfortunately happened at the same day as the MT5 update roll out
i hope this just solve the problem for now, still not trying to test with the full EA, not the dummy one.
btw, thanks everyone :)

- 2021.04.12
- www.mql5.com
I had similar problems. I found the cause in the log of the remote agents.
In my case my EA uses a custom indicator which was in DEBUG mode, while the EA was in normal mode. After recompiling my custom indicator, the remote agents run my EA properly.
So in short, check that everything your program refers to is compiled properly.
I hope this applies to your error 565 as well.
I had a same problem with the MetaTrader strategy tester, and I want to share my solution with you. It showed a strange error message like 'critical runtime error 565 in Init function (error code 565, module Experts).' After some investigation, I found out that the issue was with the timeframes I used. I also found that the error can caused by variety of things and since EA in optimization mode the errors got suppressed but if you run that iteration that cause an error in display mode you will see an error message.
In my case was timeframes. You see, in the settings, I had chosen M20 as my timeframe. But during one of my optimization tests, I used M30 as a higher timeframe for a trend filter. This caused the error! M30 cannot work with M20 bar open price modeling. Oops!
To fix this, I made sure that the timeframes in my optimization tests are compatible with the one I selected in the settings. Timeframes like M20, 1H, 2H, and so on work fine because they can be divided by M20. But using M30 with M20 bar open price modeling gives errors. The alternative is to use all ticks or 1 min OHLC modelling, that works.
So, if you encounter the 'critical runtime error 565,' double-check your timeframes and make sure they match throughout your strategy testing. I hope this helps.
Remember: When researching the solution if found that updating and/or cleaning your system may solve the problem, if not downgrade your Metatrader installation to the previous versions that works.
This was a tricky and subtle error for me also:
I was getting error 565 while testing over 1800 symbols which were rotated at runtime (overriding the symbol selected in the strategy tester Settings tab, which becomes irrelevant, or so I thought).
If the symbol in Settings was left as USDJPY, then some metals symbols like XAUAUD would give error 565 when rotated in at runtime.
If XAUAUD is set as the symbol in Settings, the problem goes away for all metals.
This was found out by running failed symbols on their own as a single test, without the optimiser.
The problem is not limited to just metals, it affects other symbols also but just experiment with the symbol in Settings until it is fixed.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi guys,
in this last few days, (i'm not quite sure when the exact date is), after updating mt5 i stuck with this "critical runtime error 565 in Oninit function" during optimization. the problem is just pop up suddenly out of nowhere, on the EA project i am currently working, and it doesn't shown such error on the optimization i did on the previous day.
i still couldn't understand where this error coming from. i even try to create some simple EA and custom indicator in hope of finding where i did wrong.
and it still shown such error.
this EA only read the change of color of the MA line from custom indicator, only 2 item was in the optimization calculation (working time frame, and period).
the custom indicator as follow (MA line using 2 pole butterworth filter)
and then the expert to read the change of line color
screenshot of the setting and journal of the test i've run are attached.
MT5 version: 5.00 build 3500 (11 Nov 2022)
could you maybe show me where did i do wrong.?
and thanks.