OnTester, OnTesterPass, OnTesterDeinit events seem not firing

 

Hello,

I'm trying to use the OnTester events, but it seems to me that they don't fire.

Code for testing:

double OnTester(){
Print ("Hello OnTester");
return(0);
}

void OnTesterPass(){
Print ("Hello OnTesterPass");
}

void OnTesterDeinit(){
Print ("Hello OnTesterDeinit");
}

After finishing the optimization I check the journal but there is nothing printed from the events:

Journal

Can you please give me a tip? I don't know what I'm doing wrong.

Best regards

Jorg

 
Joerg Hartgen: I'm trying to use the OnTester events, but it seems to me that they don't fire. Code for testing: After finishing the optimization I check the journal but there is nothing printed from the events: Can you please give me a tip? I don't know what I'm doing wrong.
During optimisations, Print() or PrintFormat() does not have any effect or output anything. Only during single test runs do they output to the log.
 
Fernando Carreiro:
During optimisations, Print() or PrintFormat() does not have any effect or output anything. Only during single test runs do they output to the log.

That's not totally exact. They can output in the terminal Experts log (not the one from the Strategy Tester).

 

@Alain: In my case there is no output to the terminal Experts log (the tab is called "Journal" in the German version) during or after optimization. Or do you mean another tab?

Tabs

I can confirm Fernandos statement: I don't see anything printed from the OnTester event.

OnTester event: As an alternative of printing I insert the information I need to a sqlite database. This works perfect.


Settings: Custom Symbol

Settings

 
Alain Verleyen: That's not totally exact. They can output in the terminal Experts log (not the one from the Strategy Tester).

They do? I've never seen that happen before!

EDIT: Ran a quick test and nothing was printed to the "Experts" or "Journal" log in the "Toolbox" section. Is there some option to enable this?

EDIT2: As per the official documentation notes:

Print() function does not work during optimization in the Strategy Tester.

PrintFormat() function does not work during optimization in the Strategy Tester.

Documentation on MQL5: Common Functions / Print
Documentation on MQL5: Common Functions / Print
  • www.mql5.com
Print - Common Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Joerg Hartgen: @Alain: In my case there is no output to the terminal Experts log (the tab is called "Journal" in the German version) during or after optimization. Or do you mean another tab? I can confirm Fernandos statement: I don't see anything printed from the OnTester event.
@Alain Verleyen is referring the "Experts" log, in the "Toolbox" section, not the "Strategy Tester" section. However, I have never seen that happen either. Maybe he can provide more details of when that can happen.
 
Fernando Carreiro:
@Alain Verleyen is referring the "Experts" log, in the "Toolbox" section, not the "Strategy Tester" section. However, I have never seen that happen either. Maybe he can provide more details of when that can happen.

Exactly. 

void OnTesterInit()
  {
   Print("Begin...");
  }
//+------------------------------------------------------------------+
void OnTesterPass()
  {
   ulong  pass=0;
   string name="";
   long   id=0;
   double value=0.0;
   double data[];

   while(FrameNext(pass,name,id,value,data))
     {
      Print(pass," ",name," ",id," ",value);
     }
  }
//+------------------------------------------------------------------+
void OnTesterDeinit()
  {
   Print("... end.");
  }


 
Alain Verleyen: Exactly. 

Ok, so the Print() only outputs to the "Experts" log if it is in the OnTester???() event handlers but not if it is in the OnTick() or OnInit() handler. Strange behavior!

Thank you for explaining it!

 
Fernando Carreiro:

Ok, so the Print() only outputs to the "Experts" log if it is in the OnTester???() event handlers but not if it is in the OnTick() or OnInit() handler. Strange behavior!

Thank you for explaining it!

It's not strange, it's just Metaquotes way and mainly undocumented. It's like 2 EAs in one, you are just not accustomed yet with the concept.

Reason: