Download MetaTrader 5

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

To add comments, please log in or register
VabRus
105
VabRus 2013.12.14 18:53 

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.

Simon Gniadkowski
Moderator
18003
Simon Gniadkowski 2013.12.14 19:27  
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.
VabRus
105
VabRus 2013.12.14 20:25  

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.

whroeder1
14764
whroeder1 2013.12.14 21:10  
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
Ubzen
5394
Ubzen 2013.12.14 21:53  
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
whroeder1
14764
whroeder1 2013.12.14 22:40  
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.
Ubzen
5394
Ubzen 2013.12.14 22:42  
WHRoeder: Deinit is run each pass. My posted code depends on it.
I taught so too... thats why I performed the test :)
VabRus
105
VabRus 2013.12.14 22:48  
WHRoeder:
Deinit is run each pass. My posted code depends on it.


Yes, I have a counter for every deinit()
Ubzen
5394
Ubzen 2013.12.14 22:58  
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);
}
VabRus
105
VabRus 2013.12.14 23:03  
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();

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

123
To add comments, please log in or register