strategy tester - not showing a message

 

Hello everyone,

I would appreciate your help since I am not so familiar with mql4.

Thank you in advance.

My goal:

To show the message "CHECK" somewhere when testing in the strategy tester.

I run the code several times in several time frames and markets. Nevertheless, the message was not shown in the:

1) journal, report or results of the tester

2) journal, expert, alerts, mailbox, news of the terminal

3) log files

However, when the code was running live, it worked and I got a message every 15 secs.

And exactly, this ("CHECK") is what I want to see to figure out if the code works over a longer period of time.

#property strict


int OnInit()
  {
   
   EventSetTimer(15);
   return(INIT_SUCCEEDED);
  }


// expert deinitialization function
void OnDeinit(const int reason)
  {
   
  }

// expert tick function
void OnTick()
  {

  }

// timer function
void OnTimer()
  {
       
               Print ("CHECK");
               Comment ("CHECK");
               MessageBox ("CHECK");
    
    
         return;
Documentation on MQL5: Language Basics / Data Types / Typecasting
Documentation on MQL5: Language Basics / Data Types / Typecasting
  • www.mql5.com
Typecasting - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
  1. Please edit your post and use the </> (Alt-S) for your code sample. Don't just paste code as plain text. It makes the code difficult to read.
  2. MessageBox() function does not work in the Strategy Tester.
  3. Comment() will only apear on the chart when testing in Visual Mode.
  4. Print() will apear in the tester's Journal log, but only for single tests. It will not appear during optimisations.
  5. Timer and ChartEvent events are not handled in the MT4 Strategy Tester.
MessageBox - Common Functions - MQL4 Reference
MessageBox - Common Functions - MQL4 Reference
  • docs.mql4.com
MessageBox - Common Functions - MQL4 Reference
 
Fernando Carreiro #:
  1. Please edit your post and use the </> (Alt-S) for your code sample. Don't just paste code as plain text. It makes the code difficult to read.
  2. MessageBox() function does not work in the Strategy Tester.
  3. Comment() will only apear on the chart when testing in Visual Mode.
  4. Print() will apear in the tester's Journal log, but only for single tests. It will not appear during optimisations.
  5. Timer and ChartEvent events are not handled in the MT4 Strategy Tester.

Thank you Fernando. I appreciate your help.

Now I understand it a little bit better. :)

 
Fernando Carreiro #:
  1. Please edit your post and use the </> (Alt-S) for your code sample. Don't just paste code as plain text. It makes the code difficult to read.
  2. MessageBox() function does not work in the Strategy Tester.
  3. Comment() will only apear on the chart when testing in Visual Mode.
  4. Print() will apear in the tester's Journal log, but only for single tests. It will not appear during optimisations.
  5. Timer and ChartEvent events are not handled in the MT4 Strategy Tester.

Hello Fernando,


Now I changed the code. However, I do not see any note when it is running in the strategy tester. How can someone test an EA, when the signals wished to be shown are nowhere listed or recorded.

I also changed the EventSetTimer to 15 sec or 1,800 sec. Nothing changes. I also do not use optimization, but use the virtual mode.

I would like to see something like this:

Time                                      Messages

2022.12.06 22:20:00               CHECK

2022.12.06 22:2x:xx               CHECK

2022.12.06 22:2x:xx               CHECK

#property strict


int OnInit()
  {
   EventSetTimer(1800);
   Comment ("CHECK");
   Print ("CHECK");
   return(INIT_SUCCEEDED);
  }


// expert deinitialization function
void OnDeinit(const int reason)
  {
   
  }

// expert tick function
void OnTick()
  {

  }

// timer function
void OnTimer()
  {
   return;
 
tylerdd #:Hello Fernando, Now I changed the code. However, I do not see any note when it is running in the strategy tester. How can someone test an EA, when the signals wished to be shown are nowhere listed or recorded. The chart open while testing has the word virtual written in brackets. I also changed the EventSetTimer to 15 sec or 1,800 sec. Nothing changes. I also do not use optimization.

No such problem on my test with your code. Are you looking at the Strategy Tester Journal log?

Also, I have already stated that Timer Events are not simulated in in MT4 Strategy Tester, so setting EventSetTimer has no effect on the tester.


 
Fernando Carreiro #:

No such problem on my test with your code. Are you looking at the Strategy Tester Journal log?

Also, I have already stated that Timer Events are not simulated in in MT4 Strategy Tester, so setting EventSetTimer has no effect on the tester.


Dear Fernando,


Perfect. Thank you a lot. Now, I see it better. At the same time, I am looking for a real log book.

I used the following code for BTCUSD, which also can be run on the weekend. However, there is no log book/journal available which shows when the close of candle 1 is  higher or lower than the close of candle 2.

Is there anywhere aa log book, showing an overview/list like this for e.g.:

Time                                      Messages

2022.12.xx 20:1x:xx               short

2022.12.xx 21:1x:xx               short

2022.12.xx 22:1x:xx               long


#property strict

double   closex;
double   closey;

int      x;
int      y;

int OnInit()
  {

   return(INIT_SUCCEEDED);
  }

// expert deinitialization function
void OnDeinit(const int reason)
  {
   
  }

// expert tick function
void OnTick()
  {

  }

// timer function
void OnTimer()
  {
EventSetTimer(3600);

x=1;
y=x+1;
closex        = iClose(Symbol(),Period(),x);
closey        = iClose(Symbol(),Period(),y);

if (closex > closey)    { 
   Comment ("long");
   Print ("long");
      }
      else
   Comment ("short");
   Print ("short");
   return;
}
Files:
Capture1.JPG  135 kb
Capture2.JPG  44 kb
 
tylerdd #: Dear Fernando, Perfect. Thank you a lot. Now, I see it better. At the same time, I am looking for a real log book. I used the following code for BTCUSD, which also can be run on the weekend. However, there is no log book/journal available which shows when the close of candle 1 is  higher or lower than the close of candle 2. Is there anywhere aa log book, showing an overview/list like ...

On live trading, the Print() output appears in the Experts log, not the Journal log.


 
Fernando Carreiro #:

On live trading, the Print() output appears in the Experts log, not the Journal log.


Hello Fernando,


Somehow I do not understand fully the testing, neither live nor backtesting. However, I changed the code and with your advice to look on the "Experts" the signals appeared every 15 sec.

This gives me the chance to continue.

Thank you so much.


#property strict

double   closex;
double   closey;

int      x;
int      y;

int OnInit()
  {
EventSetTimer(15);
   return(INIT_SUCCEEDED);
  }

// expert deinitialization function
void OnDeinit(const int reason)
  {
   
  }

// expert tick function
void OnTick()
  {

  }

// timer function
void OnTimer()
  {

x=1;
y=x+1;
closex        = iClose(Symbol(),Period(),x);
closey        = iClose(Symbol(),Period(),y);

if (closex > closey)    { 
   Comment ("long");
   Print ("long");
      }
      else
   Comment ("short");
   Print ("short");
   return;
}
 
tylerdd #: Somehow I do not understand fully the testing,

OnTimer/OnChartEvent do not work in the tester.