Discussing the article: "Making a dashboard to display data in indicators and EAs" - page 3

 
Denis Kirichenko #:
So far I have found out that this is how the CHARTEVENT_CHART_CHANGE(9) event is handled.

So it is natural - when the focus is taken away from the chart window, its sizes become different.

Here is the processing:

//--- If the schedule is changed
   if(id==CHARTEVENT_CHART_CHANGE)
     {
      //--- Get the number of the chart subwindow (it may change when deleting the window of any indicator)
      this.m_wnd=this.GetSubWindow();
      //--- Get the new chart dimensions
      int w=(int)::ChartGetInteger(this.m_chart_id,CHART_WIDTH_IN_PIXELS,this.m_wnd);
      int h=(int)::ChartGetInteger(this.m_chart_id,CHART_HEIGHT_IN_PIXELS,this.m_wnd);
      //--- Determine whether the panel size is outside the chart window
      this.m_higher_wnd=this.HigherWnd();
      this.m_wider_wnd=this.WiderWnd();
      //--- If the chart height has changed - adjust the vertical position of the panel
      if(this.m_chart_h!=h)
        {
         this.m_chart_h=h;
         int y=this.m_y;
         if(this.m_y+this.m_h>h-1)
            y=h-this.m_h-1;
         if(y<1)
            y=1;
         this.Move(this.m_x,y);
        }
      //--- If the chart width has changed - adjust the horizontal position of the panel
      if(this.m_chart_w!=w)
        {
         this.m_chart_w=w;
         int x=this.m_x;
         if(this.m_x+this.m_w>w-1)
            x=w-this.m_w-1;
         if(x<1)
            x=1;
         this.Move(x,this.m_y);
        }
     }

You should try to control the focus of the chart and not react to changes in case the chart window is out of focus. Or something else along those lines. Unfortunately, I can't run and test it yet to pinpoint the exact causes and method of fixing it.

 

I went through the forum. The problem has already been discussed. For example. I added such a check to the code:

//--- If the schedule is changed
   if(id==CHARTEVENT_CHART_CHANGE)
     {
      //--- Get the number of the chart subwindow (it may change when deleting the window of any indicator)
      this.m_wnd=this.GetSubWindow();
      l ong value;
      //--- reset the error value
      ::ResetLastError();
      //--- get the value of the property
      if(!::ChartGetInteger(m_chart_id, CHART_BRING_TO_TOP, m_wnd, value))
         {
         //--- output the error message to the "Experts" log.
         Print(__FUNCTION__ + ", Error Code = ", ::GetLastError());
         return;
         }
      // if it is not displaying the graph on top of all others - exit
      if(value == 0)
         return;
      //--- Get the new chart dimensions
      int w=(int)::ChartGetInteger(this.m_chart_id,CHART_WIDTH_IN_PIXELS,this.m_wnd);
      int h=(int)::ChartGetInteger(this.m_chart_id,CHART_HEIGHT_IN_PIXELS,this.m_wnd);
      //--- Determine whether the panel size is outside the chart window
      this.m_higher_wnd=this.HigherWnd();
      this.m_wider_wnd=this.WiderWnd();
      //--- If the chart height has changed - adjust the vertical position of the panel
      if(this.m_chart_h!=h)
        {
         this.m_chart_h=h;
         int y=this.m_y;
         if(this.m_y+this.m_h>h-1)
            y=h-this.m_h-1;
         if(y<1)
            y=1;
         this.Move(this.m_x,y);
        }
      //--- If the chart width has changed - adjust the horizontal position of the panel
      if(this.m_chart_w!=w)
        {
         this.m_chart_w=w;
         int x=this.m_x;
         if(this.m_x+this.m_w>w-1)
            x=w-this.m_w-1;
         if(x<1)
            x=1;
         this.Move(x,this.m_y);
        }
     }


The bug seems to have disappeared.


Проблема с CHARTEVENT_CHART_CHANGE - Отлавливаю момент, когда изменяется размер окна графика. При переключении окон происходит событие CHARTEVENT на размер окна предыдущих установок
Проблема с CHARTEVENT_CHART_CHANGE - Отлавливаю момент, когда изменяется размер окна графика. При переключении окон происходит событие CHARTEVENT на размер окна предыдущих установок
  • 2021.12.25
  • satorifx
  • www.mql5.com
чтобы она была в зоне видимости не вылазила за пределы окна графика CHANGE так же срабатывает. 26 11 при переключении окон ресурс не удаляется при переключении окон происходит событие CHARTEVENT CHANGE
 

Another problem. The unfolding of the panel window is not processed after the indicator was first removed from the chart, and the panel was minimised, and then started again on the chart.




Tomorrow I will try to find out what the bug is....

 

Artem, another example from the subsequent article about oscillators also glitches when minimising the window and then deleting the program from the chart. It is not an indicator, but an Expert Advisor. Here:



 
Denis Kirichenko #:

Another problem. The unfolding of the panel window is not handled after the indicator was first removed from the chart, and the panel was minimised, and then re-launched on the chart.

Tomorrow I will try to find out what the bug is....

Here you can check the cause of deinitialisation and not save the panel state to global terminal variables when removing an Expert Advisor (or indicator) from the chart. This is not a solution to the problem, but its concealment. It is not good, of course. But it will do for a quick solution.

Or you need to look into this behaviour. Unfortunately, I have limited time for now.

 
Denis Kirichenko #:

I went through the forum. The problem has already been discussed. For example. I added such a check to the code:

The bug seems to have disappeared.

Thank you. I will add this panel class to my codes later. By the way, from article to article, in which this panel was used, there were all sorts of improvements. I think here is the last article where the panel was used. But I don't remember if I have refined it yet.
I have attached the code of the panel class here.

Цветные буферы в мультисимвольных мультипериодных индикаторах
Цветные буферы в мультисимвольных мультипериодных индикаторах
  • www.mql5.com
В статье пересмотрим структуру индикаторного буфера в мультисимвольных мультипериодных индикаторах и организуем вывод на график цветных буферов этих индикаторов.
Files:
Dashboard.mqh  219 kb
 

Forum on trading, automated trading systems and testing trading strategies

Discussion of the article "Making an information panel for displaying data in indicators and Expert Advisors"

Denis Kirichenko, 2024.09.23 22:26

Another problem. It does not handle the unfolding of the panel window, after the indicator was first removed from the chart, and the panel was minimised, and then started again on the chart....


Yes, in the latest version of Dashboard.mqh there is no such bug. It works.

 
Denis Kirichenko #:

Yes, in the latest version of Dashboard.mqh there is no such bug. It works.

Good.
 

The new bib also has a bug. If you start the panel on a chart, and then play with the chart window size, the panel sticks to the bottom part when the window is restored. And it doesn't want to get out of there ((


 

Artem, I have a question. In the void CDashboard::Move(int x, int y) method there is such a thing:

if(!m_higher_wnd)
     {
      if(y + h > m_chart_h - 2)
         y = m_chart_h - h - 2;
      if(y < 1)
         y = 1;
     }
   else
     {
      if(y > 1)
         y = 1;
      if(y < m_chart_h - h - 2)
         y = m_chart_h - h - 2;
     }


In particular, I'm interested in this block. I.e. if the panel height is less than the chart window, and if its Y point (upper left corner) is lower than the difference between the window height and the panel height, corrected by 2 pixels, then the upper point of the panel will be assigned the value of this difference. Why is it like this, what is the point?

In short, it is because of the CDashboard::Move(int x, int y) method that the sticking occurs. When you try to move the panel after changing the chart size, it constantly corrects the coordinates and does not allow you to move the panel window freely...