Tester / Optimizer events

 
I've had a long hiatus from MT4 so am re-learning the environment again...

I've written my methods to output my required results from each optimiser pass to an external file using OnTester().  I'd like to add a little finesse in the form of a "header" row in the file; from everything I've tried, there doesn't appear to be a single event triggered at the start or at the end of the tester optimization, so writing to my file from OnInit() or OnDeinit() is adding the header row on every pass through the optimization.  (I believe MT5 has rectified this sequence of event triggers?) Is there a way to write to a file only once at the start of the tester optimization?  The only method I've got to work so far is to read the start of the file and if it already contains the header information then don't write it again, seek to the end of the file then write the new data and close the file; but the extra looking into the file means the optimization process take substantially longer.  I am guessing I could use a global variable, but I'd have to remember to manually reset it at the start of each testing phase?
 

What I usually do, is check for the existence of my output file. If it exists, I simple open it and append to the end, but if not, I then create the file and add the header.

Obviously, you would have to remember to delete the file before starting optimization.

Alternatively, don't delete it and actually accumulate the various group runs when you are evaluating various combinations. That way you can make a global analysis of various run groupings you may have executed.

 
FMIC:

What I usually do, is check for the existence of my output file. If it exists, I simple open it and append to the end, but if not, I then create the file and add the header.


Thanks for the idea.

"If it's crazy enough, it might just work!"
Reason: