ChartScreenShot not working as expected

 

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

align_mode= ALIGN_LEFT

works as expected, it takes data from the left side of the chart window as much WIDTH as it can but this is not what I want because it misaligns the end of the charts (weekends etc).

So I tried ALIGN_RIGHT (the default) but it appears to ignore the current location of the chart, and only takes a screenshot of the most recent data instead (regardless of the navgated chart setting.0


Try this very simple script on your chart.


1. uncheck autoscroll

2. scroll back to some past time on your chart

3. run the script

4. in your Files/ folder, you will see a screenshot but it is not of the past data you were looking at, it is of the most recent data instead.


Someone please verify.

//+------------------------------------------------------------------+
//|                                                      testing.mq5 |
//|                                                  |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright ""
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {
   ChartSetInteger(0, CHART_AUTOSCROLL, 0);

   ChartScreenShot(0,"test.gif",3000,1000);
  }


build 2981


Documentation on MQL5: Chart Operations / ChartScreenShot
Documentation on MQL5: Chart Operations / ChartScreenShot
  • www.mql5.com
ChartScreenShot - Chart Operations - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Has anyone contacted the service desk regarding the problem?
 

Hello.

In this case, ChartScreenShot help should be taken literally.

align_mode=ALIGN_RIGHT

[in] Output mode of a narrow screenshot. A value of the ENUM_ALIGN_MODE enumeration. ALIGN_RIGHT means align to the right margin (the output from the end). ALIGN_LEFT means Left justify.

This means that when ALIGN_RIGHT alignment is specified, the chart will be forced to scroll to the right border, which is equivalent to executing the command

ChartNavigate(0,CHART_END,0);

This behavior was laid down many years ago (historically). And when the ChartNavigate() function was added, the behavior of the ChartScreenShot function did not change.

Therefore, if you want to get the desired effect, use the value ALIGN_LEFT for the align_mode parameter.