is it possible detect the begin and end of optimizer from code?

 

I need some way to detect from code when the tester has the first pass and the last pass.

I tryed read from the log in tester/logs... unsuccessfully, I couldn´t open this log beacuse is used by terminal.exe.

Y was thinking reading the journal tester message but it will be so much work.

Any idea?

Thanks.

 
VabRus:

I need some way to detect from code when the tester has the first pass and the last pass.

I tryed read from the log in tester/logs... unsuccessfully, I couldn´t open this log beacuse is used by terminal.exe.

Y was thinking reading the journal tester message but it will be so much work.

Any idea?

Thanks.

If you know the number of passes . . . you could increment a counter in a GlobalVariable which you have manually reset to zero before starting the optimization run.
 

Yes, I was thinking about this; but how can I know the number of passes without a previous optimization.

I am using GlobalVariables for get the best set in my opinion with a private algorithm, my intention is when the optimization finished send me a mail with the information.

 
VabRus: I am using GlobalVariables for get the best set in my opinion with a private algorithm, my intention is when the optimization finished send me a mail with the information.
Instead of trying to get and save the best, just output all runs to a file and do that post run. mt4 strategy tester - BATCH MODE - MQL4 forum
 
VabRus: Yes, I was thinking about this; but how can I know the number of passes without a previous optimization.
You don't need to ... de_initialization is ran only once when the optimization finishes.
I am using GlobalVariables for get the best set in my opinion with a private algorithm, my intention is when the optimization finished send me a mail with the information.

You cannot send mail from the tester last time I checked. Perhaps saving to file and having an expert_advisor read that file and email you the results will work for you. If you choose to use this route then filewritehistory() might be more helpful than just filewrite() because both live and tester can access that folder.

extern  int iOptimization=1;
        int iDeInit_Count=0;

void init(){}
void start(){}

void deinit(){
    iDeInit_Count++;
    if(IsOptimization()==false)return;
    int H=FileOpen("iOptimization.csv",FILE_CSV|FILE_READ|FILE_WRITE,',');
    FileWrite(H,"iDeInit_Count="+iDeInit_Count+",iOptimization="+iOptimization);
}
Output to File:
iDeInit_Count=1,iOptimization=6
 
ubzen: You don't need to ... de_initialization is ran only once when the optimization finishes.
Deinit is run each pass. My posted code depends on it.
 
WHRoeder: Deinit is run each pass. My posted code depends on it.
I taught so too... thats why I performed the test :)
 
WHRoeder:
Deinit is run each pass. My posted code depends on it.


Yes, I have a counter for every deinit()
 
VabRus:

Yes, I have a counter for every deinit()
Ok... lol. I see where I went wrong. This works.
extern  int iOptimization=1;

void init(){}
void start(){}

void deinit(){
    int Cnt=GlobalVariableGet("iDeInit_Count"); Cnt++;
    GlobalVariableSet("iDeInit_Count",Cnt);
}
 
ubzen:
You don't need to ... de_initialization is ran only once when the optimization finishes.

You cannot send mail from the tester last time I checked. Perhaps saving to file and having an expert_advisor read that file and email you the results will work for you. If you choose to use this route then filewritehistory() might be more helpful than just filewrite() because both live and tester can access that folder.

Output to File:
iDeInit_Count=1,iOptimization=6


You can send mail with a extern dll.

I don´t understand how you get that output to file.

iOptimization in your code don´t change his value and must be 1 and iDeInit_Count = 1 is normal because this variable is destroyed in every init();

 
Bad news I can´t read message from tester journal, because when journal write "optimization stopped" the last deinit() finished before.