Screenshot filename help

 
void Screenshot()
  {
     {
      //--- Prepare a text to show on the chart and a file name 
      string name=(Symbol())+TimeToString(TimeLocal(),0)+".jpg";
      //--- 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);
     }
  }

Hi.

 If anyone could so kindly help me fix this mt5 code to save a screenshot with a correct filename representing the date, time and seconds the shot was taken.

At the moment this is the result I'm getting as an example. 

GBPUSD1565895501.jpg

I would like something like this instead.

GBPUSD 2019 08 15 22:31:59 .jpg

Below is my latest effort. It saves the correct filename but with no actual file

void Screenshot()
  {
       int flags=TIME_MINUTES|TIME_SECONDS;  
     {
      //--- Prepare a text to show on the chart and a file name 
      string name=(Symbol())+TimeToString(TimeLocal(),flags)+".jpg";
      //--- 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("Screenshot saved ",name);
     }
  }

I've struggled too long with this and now I need help. Thanks.

 
royzen:

Below is my latest effort. It saves the correct filename but with no actual file

I've struggled too long with this and now I need help. Thanks.

Seems like the filename can only contain alphanumeric characters or _, so it'll work if you change this portion of your code (basically to replace ':' with '_'):

      //--- Prepare a text to show on the chart and a file name 
      string time=TimeToString(TimeLocal(),flags);
      StringReplace(time,":","_");
      string name=(Symbol())+time+".PNG";
 
Seng Joo Thio:

Seems like the filename can only contain alphanumeric characters or _, so it'll work if you change this portion of your code (basically to replace ':' with '_'):

Thank you! Thank you! Thank you!

I'm a novice programer and would not have done this without help from you guyz.

Thank you so much for responding and so quick.

Reason: