ChartScreenShot() is saving the files as empty - page 2

 
marco82ger:

Hi Alain,

thanks for your support, however it is not working. I would like to use screenshot 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?

I just checked and taking screenshot in Visual mode  of the tester is working perfectly fine.
 

I don't know if this is applicable here, but there can be problems if using TimeToString() when naming the file.

Probably you already know this.

   string name=_Symbol+TimeToString(TimeCurrent())+".PNG"; 
   Print("File Name is ",name);
   if(!ChartScreenShot(0,name,800,600))
      Print("ScreenShot failed ",ErrorDescription(GetLastError()));
   StringReplace(name,":"," ");
   Print("File Name is ",name);
   if(!ChartScreenShot(0,name,800,600))
      Print("ScreenShot failed ",ErrorDescription(GetLastError()));

The first screenshot will produce a zero KB file without the PNG extention. 

The second will work.

Incidentally, the screenshot will be taken whether in visual mode or not.

 
Keith Watford:

I don't know if this is applicable here, but there can be problems if using TimeToString() when naming the file.

Probably you already know this.

The first screenshot will produce a zero KB file without the PNG extention. 

The second will work.

Incidentally, the screenshot will be taken whether in visual mode or not.

Are you saying that you can take a screenshot in "normal" mode of the Strategy Tester ?
 
Alain Verleyen:
Are you saying that you can take a screenshot in "normal" mode of the Strategy Tester ?

Yes, but unfortunately any indicators that you may have in the tester template will not show.

I sometimes find it useful though as any objects that the EA may draw are shown.

 
Keith Watford:

Yes, but unfortunately any indicators that you may have in the tester template will not show.

I sometimes find it useful though as any objects that the EA may draw are shown.

Can you demonstrate that ? I have run the code that I am using in Visual mode, in "normal" mode and it doesn't take any screenshot.
 
Alain Verleyen:
Can you demonstrate that ? I have run the code that I am using in Visual mode, in "normal" mode and it doesn't take any screenshot.

I changed the code slightly

   if(!IsVisualMode())
      {
      string name=_Symbol+TimeToString(TimeCurrent())+".PNG";
      StringReplace(name,":"," ");
      Print("File Name is ",name);
      if(!ChartScreenShot(0,name,800,600))
         Print("ScreenShot failed ",ErrorDescription(GetLastError()));
      }

and the files

files

Yes, I did delete all files before running the test

 
Keith Watford:

I changed the code slightly

and the files

Yes, I did delete all files before running the test

You are right, it works, the code I was using was not working in "normal" mode due an other problem. However it seems Comment() are not taken into account. Anyway, good to know.

Actually checking the previous posts, I see I answered to an MT5 question, while this is well an MT4 topic, so the confusion. With MT5 Strategy Tester, you get empty screenshots whatever the testing mode used.

 
Alain Verleyen:

You are right, it works, the code I was using was not working in "normal" mode due an other problem. However it seems Comment() are not taken into account. Anyway, good to know.

Actually checking the previous posts, I see I answered to an MT5 question, while this is well an MT4 topic, so the confusion. With MT5 Strategy Tester, you get empty screenshots whatever the testing mode used.

Wow!

That's actually a step backwards for 5!

 
Alain Verleyen:
I just checked and taking screenshot in Visual mode  of the tester is working perfectly fine.

Hi Alain,

there is some discrepancy from what you and I get, I hope we can solve that in this forum. Still I get empty images.

I am using Metatrader 5 version 5.00 build 2233


Here is the code I use and in tester both in normal and visual they produce empty files. I run the code both on Mac and Windows 10, but i get the same results.

I do not know how to proceed, any ideas or help?

Thanks,

Marco

void OnTick()
  {
   TakePicture("Test_1");
   Sleep(3000);
  }
//+------------------------------------------------------------------+
  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)+ "_"+IntegerToString(tm.sec)+ "." + patternName + ".PNG"; 
    
    int chartHeight = (int)ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS, 0); 
    int chartWidth = (int)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS, 0); 
    
    bool navigator = ChartNavigate(0,CHART_END, -1000);
    bool scCapture=ChartScreenShot(0, filename, chartWidth, chartHeight, ALIGN_RIGHT); 
    
    if (scCapture && navigator) 
        PrintFormat("Take screenshot successful ");
    else PrintFormat("Take screenshot failure");

  }
 
marco82ger:

Hi Alain,

there is some discrepancy from what you and I get, I hope we can solve that in this forum. Still I get empty images.

I am using Metatrader 5 version 5.00 build 2233


Here is the code I use and in tester both in normal and visual they produce empty files. I run the code both on Mac and Windows 10, but i get the same results.

I do not know how to proceed, any ideas or help?

Thanks,

Marco

I got a temporal solution working both in Mac and Windows: let the code i posted run on MT4, only on MT4 you can catch screenshot during testing mode. 

Please, watch out when you install MT4 since there is a known issue with links for download: https://www.mql5.com/en/forum/165973/page3

Download MT4 from metaquotes downloads MT5
Download MT4 from metaquotes downloads MT5
  • 2017.04.30
  • www.mql5.com
I have contacted the service desk about this issue. This is what I sent them.... Their response.... Not a satisfactory response at all...
Reason: