Download MetaTrader 5
To add comments, please log in or register
Have you found an interesting application? Publish it in Code Base - millions of traders will appreciate that!
Marcelo Coutinho
1151
Marcelo Coutinho 2014.05.05 20:59 

Hi,

I am using the Print() function to write internal steps of the EA in order to check app consistency during its execution.

The problem is the EA started to get bigger and having more and more variables it is getting confused.

What is the easiest way to build an Windows Form to place all the variables there so we can centralize its control/ functionality?

Regards,

MRC

Rodrigo Malacarne
Moderator
9824
Rodrigo Malacarne 2014.05.05 21:01  
YouTrade:

Hi,

I am using the Print() function to write internal steps of the EA in order to check app consistency during its execution.

The problem is the EA started to get bigger and having more and more variables it is getting confused.

What is the easiest way to build an Windows Form to place all the variables there so we can centralize its control/ functionality?

Regards,

MRC

You can use input variables to control everything inside the expert advisor.
Marcelo Coutinho
1151
Marcelo Coutinho 2014.05.05 21:39  
Malacarne:
You can use input variables to control everything inside the expert advisor.

Thanks but this is okay. What I am looking for is a Windows Form to see variables during EA execution.

Rodrigo Malacarne
Moderator
9824
Rodrigo Malacarne 2014.05.05 22:20  
YouTrade:

Thanks but this is okay. What I am looking for is a Windows Form to see variables during EA execution.

I don't think it's possible (at least inside the Strategy Tester). You will have to rely on Print() statements to see which values your variables are assuming.
Rogerio Figurelli
Moderator
38575
Rogerio Figurelli 2014.05.06 00:13  
YouTrade:

Thanks but this is okay. What I am looking for is a Windows Form to see variables during EA execution.

Hi Marcelo, the best approach I can see to do this would be export data to a fast database, since you also have all history and a easy way to select the data you need.

Anyway, this is a hard/complex way and my suggestion is the same of any kernel log control, i.e., create levels of debug information.

Note that even MT5 has a similar function to log messages, and, in the same way, why you need Print() all information all time?

You just need one variable to define the level of detail you need (your debug level), and just print what really matters at the moment (equal or higher this level).

What is relevant at each level you define, so you will Print() just what really is relevant at the moment.

In the same way (debug level), and about see variables during EA execution, you can call Comment() function to display just the variables you need, even in StrategyTester too (using visual mode, of course).

Let me know if I was clear enough about these ideas.

Alain Verleyen
Moderator
30178
Alain Verleyen 2014.05.06 01:50  
YouTrade:

Thanks but this is okay. What I am looking for is a Windows Form to see variables during EA execution.

Did you try the debugger ?
Marcelo Coutinho
1151
Marcelo Coutinho 2014.05.06 18:48  
figurelli:

Hi Marcelo, the best approach I can see to do this would be export data to a fast database, since you also have all history and a easy way to select the data you need.

Anyway, this is a hard/complex way and my suggestion is the same of any kernel log control, i.e., create levels of debug information.

Note that even MT5 has a similar function to log messages, and, in the same way, why you need Print() all information all time?

You just need one variable to define the level of detail you need (your debug level), and just print what really matters at the moment (equal or higher this level).

What is relevant at each level you define, so you will Print() just what really is relevant at the moment.

In the same way (debug level), and about see variables during EA execution, you can call Comment() function to display just the variables you need, even in StrategyTester too (using visual mode, of course).

Let me know if I was clear enough about these ideas.

Very clear. Did not know about this (debug level). Will work on that ! Thank you.
Marcelo Coutinho
1151
Marcelo Coutinho 2014.05.06 18:51  
angevoyageur:
Did you try the debugger ?

Yes I did but let me ask you something about it ...

When you debug an intraday chart you are actually stopping "time" to evaluate the variables. If the system runs on a tick basis, Even If I take too much time, the Debug will evaluate the values tick by tick or (2) next time I run the OnTick(), it will take the actual condition.

Regards,

Rogerio Figurelli
Moderator
38575
Rogerio Figurelli 2014.05.06 19:04  
YouTrade:
Very clear. Did not know about this (debug level). Will work on that ! Thank you.

You are welcome!

Below you have MT5 standard for log level, maybe you can use the same design pattern (https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradeloglevel).

Log_level = 0 - logging disabled (used in optimization mode).
Log_level = 1 - logging error messages (default).
Log_level = 2 - logging all messages (used in testing mode).

But if you need more levels, a good reference is the loglevel of Linux (syslog) below:

The loglevel
       The kernel routine printk() will only print a message on the console,
       if it has a loglevel less than the value of the variable
       console_loglevel.  This variable initially has the value
       DEFAULT_CONSOLE_LOGLEVEL (7), but is set to 10 if the kernel command
       line contains the word "debug", and to 15 in case of a kernel fault
       (the 10 and 15 are just silly, and equivalent to 8).  This variable
       is set (to a value in the range 1-8) by a syslog() call with a type
       of 8.  Calls to syslog() with type equal to 6 or 7 set the variable
       to 1 (kernel panics only) or 7 (all except debugging messages),
       respectively.

       Every text line in a message has its own loglevel.  This level is
       DEFAULT_MESSAGE_LOGLEVEL - 1 (6) unless the line starts with <d>
       where d is a digit in the range 1-7, in which case the level is d.
       The conventional meaning of the loglevel is defined in
       <linux/kernel.h> as follows:

       #define KERN_EMERG    "<0>"  /* system is unusable               */
       #define KERN_ALERT    "<1>"  /* action must be taken immediately */
       #define KERN_CRIT     "<2>"  /* critical conditions              */
       #define KERN_ERR      "<3>"  /* error conditions                 */
       #define KERN_WARNING  "<4>"  /* warning conditions               */
       #define KERN_NOTICE   "<5>"  /* normal but significant condition */
       #define KERN_INFO     "<6>"  /* informational                    */
       #define KERN_DEBUG    "<7>"  /* debug-level messages             */
Documentation on MQL5: Standard Library / Trade Classes / CTrade / LogLevel
Documentation on MQL5: Standard Library / Trade Classes / CTrade / LogLevel
  • www.mql5.com
Standard Library / Trade Classes / CTrade / LogLevel - Documentation on MQL5
Marcelo Coutinho
1151
Marcelo Coutinho 2014.05.06 19:23  
figurelli:

You are welcome!

Below you have MT5 standard for log level, maybe you can use the same design pattern (https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade/ctradeloglevel).

But if you need more levels, a good reference is the loglevel of Linux (syslog) below:

Jesus ! Were can I put this ? Do y have an example ?

I was writting something like this ...

void Report(int x)
  {
   switch(x)
     {
      case 1:
         Print("contratos: ",contratos," ContratosAtual: ",ContratosAtual," ContratoDobrado: ",ContratoDobrado);
         break;
      case 2:
         Print("contratos: ",contratos," ContratosAtual: ",ContratosAtual," ContratoDobrado: ",ContratoDobrado);
         Print("order: ",order," orderAtual: ",orderAtual);
         break;
      case 3:
         Print("contratos: ",contratos," ContratosAtual: ",ContratosAtual," ContratoDobrado: ",ContratoDobrado);
         Print("order: ",order," orderAtual: ",orderAtual);
         Print("iMA_buf1[1]: ",DoubleToString(iMA_buf1[1],6)," iMA_buf2[1]: ",DoubleToString(iMA_buf2[1],6)," iMA_buf1[0]: ",DoubleToString(iMA_buf1[0],6)," iMA_buf2[0]: ",DoubleToString(iMA_buf2[0],6));
         break;
      default:
         Print("contratos: ",contratos," ContratosAtual: ",ContratosAtual," ContratoDobrado: ",ContratoDobrado);
         Print("order: ",order," orderAtual: ",orderAtual);
         Print("iMA_buf1[1]: ",DoubleToString(iMA_buf1[1],6)," iMA_buf2[1]: ",DoubleToString(iMA_buf2[1],6)," iMA_buf1[0]: ",DoubleToString(iMA_buf1[0],6)," iMA_buf2[0]: ",DoubleToString(iMA_buf2[0],6));
         Print("iMA_buf1[1]-iMA_buf2[1]: ",DoubleToString(iMA_buf1[1]-iMA_buf2[1],6)," iMA_buf1[0]-iMA_buf2[0]: ",DoubleToString(iMA_buf1[0]-iMA_buf2[0],6));
         break;
     }
  }
Rogerio Figurelli
Moderator
38575
Rogerio Figurelli 2014.05.06 19:29  
YouTrade:

Yes I did but let me ask you something about it ...

When you debug an intraday chart you are actually stopping "time" to evaluate the variables. If the system runs on a tick basis, Even If I take too much time, the Debug will evaluate the values tick by tick or (2) next time I run the OnTick(), it will take the actual condition.

Regards,

This question reminds me that old Chinese Proverb ... "Four things come not back: the spoken word, the spent arrow, the past life, and the neglected opportunity."

In the same way, the lost tick at MT5 debugger, or even in no emulation mode, come not back. 

 


/ /12
To add comments, please log in or register