Discussion of article "Visualizing trading strategy optimization in MetaTrader 5" - page 3

 
Rashid Umarov:

@Dennis Kirichenko Did you unpack the pictures from the EasyAndFastGUI.zip archive by yourself ? I had to attach all the pictures as a ZIP-file, there is no other option at the moment.

Yes, I unzipped and copied them myself. Should you have done it differently?

I'm like this now:



 
Dennis Kirichenko:

Yes, I unzipped and copied it myself. Should I have done it differently?

I'm like this now:

All correct.

Show the list of graphical objects created by the Expert Advisor before leaving the chart at the beginning of optimisation (Ctrl + B).

 
Anatoli Kazharski:

That's right.

Show the list of graphical objects created by the Expert Advisor before leaving the chart at the beginning of optimisation (Ctrl + B).

Just in case, the objects are hidden. To show them in the list, I press the "All" button.



 
Dennis Kirichenko:

...

That is, for some reason you don't have an object created to draw the button:

standard library:

//+------------------------------------------------------------------+
//| Attach new object with bitmap resource |
//+------------------------------------------------------------------+
bool CCanvas::Attach(const long chart_id,const string objname,ENUM_COLOR_FORMAT clrfmt=COLOR_FORMAT_XRGB_NOALPHA)
  {
   if(OBJ_BITMAP_LABEL==ObjectGetInteger(chart_id,objname,OBJPROP_TYPE))
     {
      string rcname=ObjectGetString(chart_id,objname,OBJPROP_BMPFILE);
      rcname=StringSubstr(rcname,StringFind(rcname,"::"));
      if(ResourceReadImage(rcname,m_pixels,m_width,m_height))
        {
         m_objname=objname;
         m_rcname=rcname;
         m_format=clrfmt;
         m_objtype=OBJ_BITMAP_LABEL;
         //--- success
         return(true);
        }
     }
//--- failed
   return(false);
  }

//---

And it is unclear why the problem appears for some users and not for others.

Have you made any changes to this class?

 

Buttons are there.

I never edit SB.

I haven't made any changes to the CCanvas::Attach() class. Here it is:

//+------------------------------------------------------------------+
//| Attach new object with bitmap resource |
//+------------------------------------------------------------------+
bool CCanvas::Attach(const long chart_id,const string objname,ENUM_COLOR_FORMAT clrfmt=COLOR_FORMAT_XRGB_NOALPHA)
  {
   if(OBJ_BITMAP_LABEL==ObjectGetInteger(chart_id,objname,OBJPROP_TYPE))
     {
      string rcname=ObjectGetString(chart_id,objname,OBJPROP_BMPFILE);
      rcname=StringSubstr(rcname,StringFind(rcname,"::"));
      if(ResourceReadImage(rcname,m_pixels,m_width,m_height))
        {
         m_objname=objname;
         m_rcname=rcname;
         m_format=clrfmt;
         m_objtype=OBJ_BITMAP_LABEL;
         //--- success
         return(true);
        }
     }
//--- failed
   return(false);
  }
 
Dennis Kirichenko:

There are buttons.

I never edit the SB.

I haven't made any changes to the CCanvas::Attach() class. Here it is:

I can't help you in this case.

KR      0       12:44:52.304    MacdSampleWithFrames (EURUSD,H1)        CElement::CreateCanvas > Не удалось присоединить холст для рисования к графику: 4016

//---

Error 4016 means:

ERR_RESOURCE_NOT_FOUND

4016

Resource with this name was not found in EX5


//---

If anyone else has tested the examples from the article, please tell me about the results. Does anyone else experience this problem?

 

Could it be because my root folder is "C:/Program Files / MetaTrader 5 / MQL5"????

Accordingly, the resources are located in C:\Program Files\MetaTrader 5\MQL5\Images.

Maybe there is a problem with accessing the images? Although the terminal is started as administrator.

 
Dennis Kirichenko:

Could it be because my root folder looks like "C:\Program Files\MetaTrader 5\MQL5"??? ?

Accordingly, the resources are located in C:\Program Files/ MetaTrader 5/ MetaTrader 5/ MQL5/Images.

Maybe there is a problem with accessing the images? Although the terminal runs as administrator.

I don't know. Try to investigate this point.

The resources in the code for the form are written like this:

//+------------------------------------------------------------------+
//|| Creates buttons on the form|
//+------------------------------------------------------------------+
#resource "\\Images\\EasyAndFastGUI\\Controls\\close_black.bmp"
#resource "\\Images\\EasyAndFastGUI\\Controls\\close_white.bmp"
#resource "\\Images\\EasyAndFastGUI\\Controls\\full_screen.bmp"
#resource "\\Images\\EasyAndFastGUI\\Controls\\minimize_to_window.bmp"
#resource "\\Images\\EasyAndFastGUI\\Controls\\up_thin_white.bmp"
#resource "\\Images\\EasyAndFastGUI\\Controls\\down_thin_white.bmp"
#resource "\\Images\\EasyAndFastGUI\\Controls\\help.bmp"
//---
bool CWindow::CreateButtons(void)
  {
//--- If the programme type is "script", exit
   if(CElementBase::ProgramType()==PROGRAM_SCRIPT)
      return(true);
//--- Count, size, quantity
   int i=0,x_size=20;
   int buttons_total=4;
//--- File path
   string icon_file="";
//--- Exception in the capture area
   m_right_limit=0;
//---
   CButton *button_obj=NULL;
//---
   for(int b=0; b<buttons_total; b++)
     {
      //---
      if(b==0)
        {
         CElementBase::LastId(LastId()-1);
         m_button_close.MainPointer(this);
         if(!m_close_button)
            continue;
         //---
         button_obj=::GetPointer(m_button_close);
         icon_file ="Images\\EasyAndFastGUI\\Controls\\close_white.bmp";
        }
      else if(b==1)
        {
         m_button_fullscreen.MainPointer(this);
         //--- Exit if (1) the button is not enabled or (2) this dialogue window
         if(!m_fullscreen_button || m_window_type==W_DIALOG)
            continue;
         //---
         button_obj=::GetPointer(m_button_fullscreen);
         icon_file="Images\\EasyAndFastGUI\\Controls\\full_screen.bmp";
        }
      else if(b==2)
        {
         m_button_collapse.MainPointer(this);
         //--- Exit if (1) the button is not enabled or (2) this dialogue window
         if(!m_collapse_button || m_window_type==W_DIALOG)
            continue;
         //---
         button_obj=::GetPointer(m_button_collapse);
         if(m_is_minimized)
            icon_file="Images\\EasyAndFastGUI\\Controls\\down_thin_white.bmp";
         else
            icon_file="Images\\EasyAndFastGUI\\Controls\\up_thin_white.bmp";
        }
      else if(b==3)
        {
         m_button_tooltip.MainPointer(this);
         //--- Exit if (1) the button is not enabled or (2) this dialogue window
         if(!m_tooltips_button || m_window_type==W_DIALOG)
            continue;
         //---
         button_obj=::GetPointer(m_button_tooltip);
         icon_file ="Images\\EasyAndFastGUI\\Controls\\help.bmp";
        }
      //--- Properties
      button_obj.Index(i);
      button_obj.XSize(x_size);
      button_obj.YSize(x_size);
      button_obj.IconXGap(2);
      button_obj.IconYGap(2);
      button_obj.BackColor(m_caption_color);
      button_obj.BackColorHover((b<1)? C'242,27,45' : C'0,150,245');
      button_obj.BackColorPressed((b<1)? C'149,68,116' : C'0,160,255');
      button_obj.BackColorLocked(m_caption_color_locked);
      button_obj.BorderColor(m_caption_color);
      button_obj.BorderColorHover(m_caption_color);
      button_obj.BorderColorLocked(m_caption_color_locked);
      button_obj.BorderColorPressed(m_caption_color);
      button_obj.IconFile(icon_file);
      button_obj.IconFileLocked(icon_file);
      if(b==3)
        {
         button_obj.TwoState(true);
         button_obj.IconFilePressed(icon_file);
         button_obj.IconFilePressedLocked(icon_file);
        }
      button_obj.AnchorRightWindowSide(true);
      //--- Indentation calculation for the next button
      m_right_limit+=x_size-((i<3)? 0 : 1);
      i++;
      //--- Create an element
      if(!button_obj.CreateButton("",m_right_limit,0))
         return(false);
      //--- Add an element to the array
      CElement::AddToArray(button_obj);
     }
//---
   return(true);
  }
 

Yes, Anatoly, I have discovered this.

In your code samples to the article, in the downloaded files, the MacdSampleWithFrames.mq5 file is identical to the MovingAverageWithFrames.mq5 file in terms of code content.

Please correct it. Thank you.

 

I tested it on another terminal where all files are stored in the %AppData\Roaming\MetaQuotes\Terminal\... folder.

Same error. Something's wrong somewhere.