Picture of chart is not maximized during screenshot

 

Hello,

I hope somebody can help me with my problem.

The problem concerns to mql4, I don't know that is a good place of this topic.

I have open several charts and on each of them is working EA. If EA will open or close position I'm doing screenshot. To do this I need to bring chart to top using this ChartSetIntiger(0,BRING_TO_TOP,true).

From time to time screenshot looks like this belowe on picture. Chart in not displayed in a whole window but chart window is maximized. Rest of window is blank. Chart take place only a part of a whole window. Somebody know where can be a problem?

    

Files:
 
  1. Assuming that bring to top is synchronous? We can't see your code.
  2. Auto-scroll not set?
 

Hello,

Regard to synchronisation I'm waiting maksimum 3 seconds as long as chart will be on top. Below you can see main function.  

void Events_02_ScreenShotHandler()
   {
   if(gEvents.make_screenshot!=0)
      {
      //---
      for(int i=1; i<=3; i++)
         {
         if(ChartGetInteger(ChartID(),CHART_BRING_TO_TOP)==false)
            {
            ChartSetInteger(ChartID(),CHART_BRING_TO_TOP,true)
            Sleep(1000);
            }
         else
            {
            break;
            }
         }

      if(ChartGetInteger(ChartID(),CHART_BRING_TO_TOP)==true)
         {
         switch(gEvents.make_screenshot)
            {
            case 1:
               Events_03_MakeScreenShot("OPEN",false);
               break;

            case 2:
               Events_03_MakeScreenShot("CLOSE",false);
               break;

            case 3:
               Events_03_MakeScreenShot("LATER",false);
               break;

            case 4:
               Events_03_MakeScreenShot("ERROR",false);
               break;

            case 5:
               Events_03_MakeScreenShot("MANUAL",false);
               break;

            default:
               Events_03_MakeScreenShot("",false);
               break;
            }
         }
      }

   //--- reset
   gEvents.make_screenshot = 0;

   return;
   }

There is another function responsible for creation path and file name and that works fine. On the end it is making screenshot.

void Events_03_MakeScreenShot(string Mode,bool MonthWeek)
   {
   ENUM_ALIGN_MODE align;
   string subfolder,month_name,data,comment,file_name,fill_zero,path,name;
   int month_number,week_number,last_file_num;
   long search_handle;
   int gScreanShotsCnt = 0;

   long height = ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
   long width  = ChartGetInteger(0,CHART_WIDTH_IN_PIXELS,0);

   if(IsTesting())
      {
      // Save when offline during testing
      subfolder = gInputs.events.folder_name_offline;
      month_number = GlobalVariableGet("gData_Month");
      week_number = Helper_07_ReturnWeekNumber();
      }
   else
      {
      // Save when online
      subfolder = gInputs.events.folder_name_online;
      month_number = Month();
      week_number = Helper_07_ReturnWeekNumber();
      }

// Determine name of month folder depend of month number
   switch(month_number)
      {
      case  1:
         month_name = "01 - styczen";
         break;
      case  2:
         month_name = "02 - luty";
         break;
      case  3:
         month_name = "03 - marzec";
         break;
      case  4:
         month_name = "04 - kwiecien";
         break;
      case  5:
         month_name = "05 - maj";
         break;
      case  6:
         month_name = "06 - czerwiec";
         break;
      case  7:
         month_name = "07 - lipiec";
         break;
      case  8:
         month_name = "08 - sierpien";
         break;
      case  9:
         month_name = "09 - wrzesien";
         break;
      case 10:
         month_name = "10 - pazdziernik";
         break;
      case 11:
         month_name = "11 - listopad";
         break;
      case 12:
         month_name = "12 - grudzien";
         break;
      }

// FOLDER PATH
   if( MonthWeek) path = subfolder+"\\"+month_name+"\\"+Symbol();
   if(!MonthWeek) path = subfolder+"\\"+"Tydzien_"+week_number+"\\"+Symbol();

// FILE NAME
   data = Hour()+"."+Minute()+"."+Seconds()+" "+Day()+"."+Month()+"."+Year()+" "+Symbol();


// CREATE FOLDER
   FolderCreate(path);

// It search first file in folder
   search_handle = FileFindFirst(path+"\\"+"*",file_name);

// Name of event - OPEN/CLOSE/ERROR/MANULAL etc.
   comment = Mode+".png";

// If folder is not empty do this:
   if(search_handle!=INVALID_HANDLE)
      {
      // Find folder name in \\month\\symbol\\...
      do
         {
         ResetLastError();
         }
      while(FileFindNext(search_handle,file_name));

      // Get first two sign of name - it means oder number
      last_file_num = StringToInteger(StringSubstr(file_name,0,2));
      // Increment this order number
      last_file_num = last_file_num+1;
      // Fill by "0" if is example "3" -> "03"
      if(last_file_num<10)
         {
         fill_zero = "0";
         }
      else
         {
         fill_zero = "";
         }

      path = path+"\\"+fill_zero+last_file_num+"  "+data+" "+comment;

      // Determine parameters of screenshot
      double fvb = WindowFirstVisibleBar();
      double bpc = WindowBarsPerChart();
      double factor = (fvb/bpc)*100;

      if(factor<=75)
         {
         align = ALIGN_RIGHT;
         }
      else
         {
         align = ALIGN_CENTER;
         }

      // Do screenshot
      ChartScreenShot(0,path+name,width+80,height,align);

      FileFindClose(search_handle);
      }
// If folder is empty do this:
   else
      {
      align = ALIGN_RIGHT;
      path = path+"\\"+"00"+"  "+data+" "+comment;

      // Do screenshot
      ChartScreenShot(0,path,width+80,height,align);

      }

   return;
   }
 
formalmail #: Regard to synchronisation I'm waiting maksimum 3 seconds a
            ChartSetInteger(ChartID(),CHART_BRING_TO_TOP,true)
            Sleep(1000);

You added the command to the event queue. Nothing will happen until you return. You are not waiting, you are blocking.

 

Ok, I putted this function to OnTimer and if three second will passed then I go to next part of code. I added settings of chart like you mentioned and we will see what will happen through next week.

For now thank you.

 

Hello,

I would like to mention that if we whant to make a screenshot we don't need to bring the chart on top, we need only call function ChartScreenShot, then we don't need to implement any synchronisation.

After update of the code all works fine.


Topic is close.

Thank you.

Reason: