Why don't you simply remove OnDeinit() from include file and extract deinit code into multiple functions and then call that from the EA's OnDeinit()
Something like this:
// Put these into mqh file void DeinitSomething() { } void DeinitSomethingElse() { } void DeinitSomeOtherthing() { } // In EA 1 do void OnDeinit(int reason) { DeinitSomething(); DeinitSomethingElse(); } // In EA 2 do void OnDeinit(int reason) { DeinitSomething(); DeinitSomeOtherthing(); }
Like Drazen showed.
Resetting static: Problem in detecting a new Bar - MQL5 programming forum #5.3 (2020)

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Maybe my problem is unusual, but it's certainly complicated, and I admit I painted myself into a corner.
I have an include file called AllMyFunctions.mqh. All my EAs begin by 'including' that file. Some EAs maye have ad hoc functions, but most functions and variables come from AllMyFunctions.mqh.
Including OnDeinit(), which has become a bit of a juggernaut inside that one include because it has to cater to many EAs. It's now becoming a little unsustainable.
Now I need a function that ends a series of "optimized" tests with a final report. I can't just do that at the end of thr EA. That would cause the report to be printed after each iteration of the loop. Only OnDeinit can issue the report correctly.
But OnDeinit() is in the juggernaut include, and this new EA has a considerable amount of both code from the include and ad hoc code of its own. It is quite happy using part of the big include and some of its own code, except for the final report. This new EA has functions and variables outside of the scope of the big include, so the include can't generate the report. And the EA can't have its own version of OnDeinit() because the compiler complains that OnDeinit has been defined already.
Is there an easy solution out of this situation? Maybe some clever kludge I can't come up with by myself?
TIA