MQL5: Clearing the [Expert] Tab window via MQL5 script / EA

 

is there a command or a function that can clear the records of the [Expert] / [Journal] tab windows?

I thought this will be an easy to find in the documentation / an internet search... 

void OnStart() {
// --- Start of the Script
// --- Is MQL 5 command / function I can clear the records of the [Expert] tab window here?
   Print("SYMBOLINFO - SAMPLE Script");
   CSymbolInfo symbol_info;
   symbol_info.Name(_Symbol);
   symbol_info.RefreshRates();
...
...
...

};

I would like to have clear [Expert] window tab when every I am executing a script / EA when looking at data. At moment, I right click on the tab window and select [Clear] each time I execute a script / EA. It kinda annoying that I have to do it each time... TIA! 

Files:
Capture.JPG  170 kb
 
simartspoako:is there a command or a function that can clear the records of the [Expert] / [Journal] tab windows? I thought this will be an easy to find in the documentation / an internet search... I would like to have clear [Expert] window tab when every I am executing a script / EA when looking at data. At moment, I right click on the tab window and select [Clear] each time I execute a script / EA. It kinda annoying that I have to do it each time... TIA! 
No, there is no such functionality. You are also defeating the purpose of the logs in the first place by doing so. Instead output your data to your own log file.
 
Fernando Carreiro #:
No, there is no such functionality. You are also defeating the purpose of the logs in the first place by doing so. Instead output your data to your own log file.
Okay thats cool... I might just display the data on the charts using Label Objects or maybe a comment command line... I don't think I need a log file :D , My purpose just need to view data when I just need it like troubleshooting & debugging... Thanks! 
 

I recommend the following solution:


We set the platform height to, for example, 7 lines in the "Terminal" window:

https://ibb.co/HYwxBrw


Next, we have an example indicator code that will execute exactly once during each change and compilation of the code (F7), which greatly helps in testing functions, values, and making further code adjustments and calculations.

//+------------------------------------------------------------------+
//|                                                   ind_LOG_RP.mq5 |
//+------------------------------------------------------------------+
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Variable declaration                                             |
//+------------------------------------------------------------------+

   bool b_CHECK;
   
   double db_MAX, db_MIN;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   b_CHECK = true;

   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   db_MAX = 1.7234;
   db_MIN = 1.1422;

   if(b_CHECK)
   {
      Print(
              "----   START   ----", "\n",
              "db_MAX: ", db_MAX, "\n", 
              "db_MIN: ", db_MIN, "\n",
              "\n",
              "\n",
              "\n",
              "----   END   ----"
           );
      b_CHECK = false;
   }

   return(rates_total);
}
//+------------------------------------------------------------------+

Best regards.


1 hosted at ImgBB
1 hosted at ImgBB
  • ibb.co
Image 1 hosted in ImgBB
 
I achieved a cool effect thanks to Chat GPT. This time everything looks similar, but there is a 5-second delay between the new and old text, which provides us with additional programming comfort. Best regards.


//+------------------------------------------------------------------+
//|                                                   ind_LOG_RP.mq5 |
//+------------------------------------------------------------------+
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 0
#property indicator_plots 0
//+------------------------------------------------------------------+
//| Variable declaration                                             |
//+------------------------------------------------------------------+

   bool b_CHECK;
   
   datetime dt_CT, dt_ST;
   
   double db_MAX, db_MIN;
   
   int z;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
   b_CHECK = true;

   return(INIT_SUCCEEDED);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
   dt_ST = TimeLocal();
   
   //---- Main program block ---------------------
   db_MAX = 1.7234;
   db_MIN = 1.1422;
   
   
   
   
   //---------------------------------------------
 
   if(b_CHECK)
   {
      for(z = 0; z < 2; z++)
      {
         if(z == 0) f_INFORMATION_1();
         
         if(z == 1) f_INFORMATION_2();
      
         Print(
                 "db_MAX: ", db_MAX, "\n", 
                 "db_MIN: ", db_MIN, "\n",
                 "\n",
                 "\n",
                 "\n",
                 "----   END   ----"
              );
           
         dt_CT = TimeLocal();
         if (dt_CT - dt_ST >= 5)
           dt_ST = dt_CT;  // Start time update
         else
         {
            // Waiting to reach 5 seconds from the beginning of the loop
            while (TimeLocal() - dt_ST < 5)
            {
                Sleep(100);  // Wait for 100 milliseconds
            }
         }
      }
      b_CHECK = false;
   }

   return(rates_total);
}
//+------------------------------------------------------------------+
void f_INFORMATION_1()
{
   Print(
           "----   START   ----   NEW CHANGE   ----"
        );
}
void f_INFORMATION_2()
{
   Print(
           "----   START   ----"
        );
}
//+------------------------------------------------------------------+

Editing:

However, the previous version is better because here, regardless, the corrections, calculations, and graphic objects will be applied to the chart only after the execution of the second loop cycle, until the entire program block is completed.