ChartScreenShot() is saving the files as empty

 

hi there

‌‌I am noticing that ChartScreenShot() is saving the files as empty (i.e. zero byte files), anyone noticing a similar result ? ChartScreenShot () function returns true btw and I am using the latest build of 1052.

I am using the following code :

int OnStart(){

     long chartid;

     chartid=ChartOpen("EURUSD",PERIOD_H1);

     string file="picture.gif";

     Alert("screenshot =",ChartScreenShot(chartid,file,800,600));

     return(0);

}‌

t‌hanks

w‌ilson

 

The new chart (ChartOpen) has no time to be opened yet. Add a Sleep(10) or something.

 
Alain Verleyen:

The new chart (ChartOpen) has no time to be opened yet. Add a Sleep(10) or something.



Ive tried Sleep(5000) after opening chart and it still does not work :(
 
wilson_wilson:

Ive tried Sleep(5000) after opening chart and it still does not work :(

That code works fine for me... is the chart opening as it should?
 
honest_knave:

That code works fine for me... is the chart opening as it should?

Yes, the chart is opening as it should, btw I think I might know what the problem is ... the code seems to work if I use it on a windows platform but not when I use it on my mac !
 

dear all, I got the same problem.

With the same function it works well in Script mode and live mode. However in backtest mode I get all empty files.

have you overcome this problem?

I just include this function on ExpertMACD.mql5 and capture chart for every new completed bar:

void TakePicture(string patternName)
//+------------------------------------------------------------------+
  {
    MqlDateTime tm;
    TimeToStruct(TimeCurrent(),tm);
    string filename= "ChartScreen\\" + IntegerToString(tm.year)
        + "\\"+Symbol()+"\\"+IntegerToString(tm.mon)
        + "\\"+IntegerToString(tm.day)+"\\"+IntegerToString(tm.hour)
        + "_"+IntegerToString(tm.min)+ "." + patternName + ".BMP";
   
    int chartHeight = (int)ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS, 0);
    int chartWidth = (int)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS, 0);
   
    bool scCapture=ChartScreenShot(0, filename, chartWidth, chartHeight, ALIGN_RIGHT);
    if (scCapture) {
        PrintFormat("Take screenshot successful ");
    } else {
        PrintFormat("Take screenshot failure");
    }
   
  }



Files:
 
wilson_wilson:

Yes, the chart is opening as it should, btw I think I might know what the problem is ... the code seems to work if I use it on a windows platform but not when I use it on my mac !
How did you solve this issue on mac?
 
Vo Mai Chi:

dear all, I got the same problem.

With the same function it works well in Script mode and live mode. However in backtest mode I get all empty files.

have you overcome this problem?

I just include this function on ExpertMACD.mql5 and capture chart for every new completed bar:

void TakePicture(string patternName)
//+------------------------------------------------------------------+
  {
    MqlDateTime tm;
    TimeToStruct(TimeCurrent(),tm);
    string filename= "ChartScreen\\" + IntegerToString(tm.year)
        + "\\"+Symbol()+"\\"+IntegerToString(tm.mon)
        + "\\"+IntegerToString(tm.day)+"\\"+IntegerToString(tm.hour)
        + "_"+IntegerToString(tm.min)+ "." + patternName + ".BMP";
   
    int chartHeight = (int)ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS, 0);
    int chartWidth = (int)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS, 0);
   
    bool scCapture=ChartScreenShot(0, filename, chartWidth, chartHeight, ALIGN_RIGHT);
    if (scCapture) {
        PrintFormat("Take screenshot successful ");
    } else {
        PrintFormat("Take screenshot failure");
    }
   
  }



During a backtest there is no chart, so the screenshot is empty.
 
Alain Verleyen:
During a backtest there is no chart, so the screenshot is empty.

Hi Alain, 

I read often your valid comments. 

I think the purpose of the post is to take screeshot on historical data, do you know how?

I have the same proble to have empty file while backtesting

Best regards

Marco

 
marco82ger:

Hi Alain, 

I read often your valid comments. 

I think the purpose of the post is to take screeshot on historical data, do you know how?

I have the same proble to have empty file while backtesting

Best regards

Marco

In Visual mode I suppose it should work, I didn't check though.
 
Alain Verleyen:
In Visual mode I suppose it should work, I didn't check though.

Hi Alain,

thanks for your support, however it is not working. I would like to use screeshot of historical charts in order to use algorithms of computer vision but I do not know how to proceed, it is now 3 weekd that I cannot produce images and I do not know how to circumvent the problem. Any suggestion or help?

Reason: