Issue with ChartScreenShot and Canvas for mql4

 

Good day guys.

I would like to ask - does anybody know if the ChartScreenShot command generates a chart event - or in any way affect chart objects? I have tried to use this to capture a chart which I open from an EA, the new chart opens with an indicator loaded to it that uses Canvas objects - bitmap labels in specific - along with other basic line and channels. The problem is, no matter how fast or slow I do the screenshot, the canvas objects always doesn't show, and only the channels/lines remain. When I observe the process, the indicator loads properly but when the screenshot captures, it just blinks, or redraws, at the time of capturing. I have tried to disqualify the possibility of this being because of a chart event by setting my event handling to only button clicks, but I still get the same odd results. Can anyone help?


Here is a sample code - which is actually just part of the Telegram Bot EA screenshot portion:

  int               SendScreenShot(const long _chat_id,
                                    const string _symbol,
                                    const ENUM_TIMEFRAMES _period,
                                    const string _template=NULL)
   {
      int result=0;

      long chart_id=ChartOpen(_symbol,_period);
      if(chart_id==0)
         return(ERR_CHART_NOT_FOUND);

      ChartSetInteger(ChartID(),CHART_BRING_TO_TOP,true);

      //--- updates chart
      int wait=60;
      while(--wait>0)
      {
         if(SeriesInfoInteger(_symbol,_period,SERIES_SYNCHRONIZED))
            break;
         Sleep(500);
      }

      if(_template!=NULL)
         if(!ChartApplyTemplate(chart_id,_template))
            PrintError(_LastError,InpLanguage);

      ChartRedraw(chart_id);
      Sleep(500);

      ChartSetInteger(chart_id,CHART_SHOW_GRID,false);

      ChartSetInteger(chart_id,CHART_SHOW_PERIOD_SEP,false);

      string filename=StringFormat("%s%d.gif",_symbol,_period);

      if(FileIsExist(filename))
         FileDelete(filename);
      ChartRedraw(chart_id);

      Sleep(100);

      if(ChartScreenShot(chart_id,filename,800,600,ALIGN_RIGHT))
      {
         
         Sleep(100);
         
         //--- Need for MT4 on weekends !!!
         ChartRedraw(chart_id);
         
         bot.SendChatAction(_chat_id,ACTION_UPLOAD_PHOTO);

         //--- waitng 30 sec for save screenshot
         wait=60;
         while(!FileIsExist(filename) && --wait>0)
            Sleep(500);

         //---
         if(FileIsExist(filename))
         {
            string screen_id;
            result=bot.SendPhoto(screen_id,_chat_id,filename,_symbol+"_"+StringSubstr(EnumToString(_period),7));
         }
         else
         {
            string mask=m_lang==LANGUAGE_EN?"Screenshot file '%s' not created.":"Файл скриншота '%s' не создан.";
            PrintFormat(mask,filename);
         }
      }

      ChartClose(chart_id);
      return(result);
   }

I have no issues with sending the files but I do no get my desired result. Does anyone know if I am missing anything?

Thanks in advance.

Reason: