ChartScreenShot issue

To add comments, please log in or register
Gabor Schnierer
176
Gabor Schnierer  

Hi Folks!

I was trying to use the command ChartScreenShot. I looked up the Docs, and downloaded the example code.

 https://www.mql5.com/en/docs/chart_operations/chartscreenshot

When I executed the code, here is what I received as result.

 Result

My problem is that according to the Documentation, the pictures should be made with a constant ChartNavigate step from both ends of the chart. This is correct for the 'Begin' pictures, but the 'END' pictures are all the same. So it looks like that ALIGN_LEFT is OK, but ALIGN_RIGHT looks as if it was disregarding the ChartNavigate command. Is this a bug? Or am I missing something?

 Thanks in advance, 

Documentation on MQL5: Chart Operations / ChartScreenShot
Documentation on MQL5: Chart Operations / ChartScreenShot
  • www.mql5.com
Chart Operations / ChartScreenShot - Reference on algorithmic/automated trading language for MetaTrader 5
Alain Verleyen
40805
Alain Verleyen  
sch007:

Hi Folks!

I was trying to use the command ChartScreenShot. I looked up the Docs, and downloaded the example code.

 https://www.mql5.com/en/docs/chart_operations/chartscreenshot

When I executed the code, here is what I received as result.

 

My problem is that according to the Documentation, the pictures should be made with a constant ChartNavigate step from both ends of the chart. This is correct for the 'Begin' pictures, but the 'END' pictures are all the same. So it looks like that ALIGN_LEFT is OK, but ALIGN_RIGHT looks as if it was disregarding the ChartNavigate command. Is this a bug? Or am I missing something?

 Thanks in advance, 

Can you post the problematic screenshot(s) alone. Your posted picture is too small to see anything.
Gabor Schnierer
176
Gabor Schnierer  
angevoyageur:
Can you post the problematic screenshot(s) alone. Your posted picture is too small to see anything.

Indeed. I have attached them all below. Though I think the problem is visible on the low-res version too. In high-res its more comfortable, I agree.
Just in case my description of the issue was unclear, I'll rephrase it. The example code in the docs should produce different pictures for both image-series: for both END and BEGIN. END pictures are not different.

BEGIN 

BEGIN0 

BEGIN300 

 BEGIN600

 BEGIN900

BEGIN1200 

 

END 

END0

 END300

 END600

END900 

END1200 

Alain Verleyen
40805
Alain Verleyen  
sch007:

Indeed. I have attached them all below. Though I think the problem is visible on the low-res version too. In high-res its more comfortable, I agree.
Just in case my description of the issue was unclear, I'll rephrase it. The example code in the docs should produce different pictures for both image-series: for both END and BEGIN. END pictures are not different.

Ok, thank you. But how can we know there is an error/bug as we don't see the code that produces these screenshot ?

Gabor Schnierer
176
Gabor Schnierer  
angevoyageur:

Ok, thank you. But how can we know there is an error/bug as we don't see the code that produces these screenshot ?

Thank you for your answers! I will paste the code here. This is the code that produced the pictures. You can also find it in the documentation.

https://www.mql5.com/en/docs/chart_operations/chartscreenshot

#property description "The Expert Advisor demonstrates how to create a series of screenshots of the current"
#property description "chart using the ChartScreenShot() function. For convenience, the file name is"
#property description "shown on the chart. The height and width of images is defined through macros."

 
#define        WIDTH  800     // Image width to call ChartScreenShot()
#define        HEIGHT 600     // Image height to call ChartScreenShot()
 
//--- input parameters
input int      pictures=5;    // The number of images in the series
int            mode=-1;       // -1 denotes a shift to the right edge of the chart, 1 - to the left
int            bars_shift=300;// The number of bars when scrolling the chart using ChartNavigate()
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- Disable chart autoscroll
   ChartSetInteger(0,CHART_AUTOSCROLL,false);
//--- Set the shift of the right edge of the chart
   ChartSetInteger(0,CHART_SHIFT,true);
//--- Show a candlestick chart
   ChartSetInteger(0,CHART_MODE,CHART_CANDLES);
//---
   Print("Preparation of the Expert Advisor is completed");
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
 
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//--- Show the name of the function, call time and event identifier
   Print(__FUNCTION__,TimeCurrent(),"   id=",id,"   mode=",mode);
//--- Handle the CHARTEVENT_CLICK event ("A mouse click on the chart")
   if(id==CHARTEVENT_CLICK)
     {
      //--- Initial shift from the chart edge
      int pos=0;
      //--- Operation with the left chart edge
      if(mode>0)
        {
         //--- Scroll the chart to the left edge
         ChartNavigate(0,CHART_BEGIN,pos);
         for(int i=0;i<pictures;i++)
           {
            //--- Prepare a text to show on the chart and a file name
            string name="ChartScreenShot"+"CHART_BEGIN"+string(pos)+".gif";
            //--- Show the name on the chart as a comment
            Comment(name);
            //--- Save the chart screenshot in a file in the terminal_directory\MQL5\Files\
            if(ChartScreenShot(0,name,WIDTH,HEIGHT,ALIGN_LEFT))
               Print("We've saved the screenshot ",name);
            //---
            pos+=bars_shift;
            //--- Give the user time to look at the new part of the chart
            Sleep(3000);
            //--- Scroll the chart from the current position bars_shift bars to the right
            ChartNavigate(0,CHART_CURRENT_POS,bars_shift);
           }
         //--- Change the mode to the opposite
         mode*=-1;
        }
      else // Operation with the right chart edge
        {
         //--- Scroll the chart to the right edge
         ChartNavigate(0,CHART_END,pos);
         for(int i=0;i<pictures;i++)
           {
            //--- Prepare a text to show on the chart and a file name
            string name="ChartScreenShot"+"CHART_END"+string(pos)+".gif";
            //--- Show the name on the chart as a comment
            Comment(name);
            //--- Save the chart screenshot in a file in the terminal_directory\MQL5\Files\
            if(ChartScreenShot(0,name,WIDTH,HEIGHT,ALIGN_RIGHT))
               Print("We've saved the screenshot ",name);
            //---
            pos+=bars_shift;
            //--- Give the user time to look at the new part of the chart
            Sleep(3000);
            //--- Scroll the chart from the current position bars_shift bars to the right
            ChartNavigate(0,CHART_CURRENT_POS,-bars_shift);
           }
         //--- Change the mode to the opposite
         mode*=-1;
        }
     }  // End of CHARTEVENT_CLICK event handling
//--- End of the OnChartEvent() handler  
  }
Documentation on MQL5: Chart Operations / ChartScreenShot
Documentation on MQL5: Chart Operations / ChartScreenShot
  • www.mql5.com
Chart Operations / ChartScreenShot - Reference on algorithmic/automated trading language for MetaTrader 5
Gabor Schnierer
176
Gabor Schnierer  
I guess I will just report this as bug in the service desk.
gr101
150
gr101  
Any resolution on this?
Mano
12
Mano  
Same bug here
To add comments, please log in or register