Running the optimizer/backtester from within the EA

 
This may be a tricky question. But here goes:

I have an EA that I want to run with some parameters that must be derived from earlier performance of the same EA in an optimizer.

In other words, before trading on Tuesday, I want to run the EA optimized for two parameters for Monday, then from the results of Monday, I want to use the optimized data for the parameters on Tuesday.

Then the same would be done for Wednesday, etc.

But of course, I want to have the EA automatically do the process instead of manually doing it every week. I know it is easy if you want to do it manually. But the idea is to make the optimization process automatically within the EA, then running the EA with the built-in optimizer in a backtesting mode to see how this affects its performance.

A bit messy? I know. But I hope someone who had done something like this in the past help me out here...

Thanks
 
You can use files or Global Variables to pass parameters between testing passes
 
Thanks, but could you kindly elaborate? An example could be very useful.

Let's say I have an EA that uses two parameters only.

So within this EA, I can setup a function to run the EA on the backtester while trying various parameters and get the best ones?
Reason: