Download MetaTrader 5
To add comments, please log in or register
Subscribe to signals right in MetaTrader. It is easy!
Robert Browne
88
Robert Browne 2016.06.27 22:55 

From the diaries of the worlds worst programmer.

So I have implemented the following code in my bot, the idea is to take a screenshot OnTimer and on a button click

 

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void TakePicture()
//+------------------------------------------------------------------+
  {
   string filename= "ScreenShot\\"+Symbol()+"\\"+TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)+".png";
   int ChartWidth = guiGetChartWidth(hwnd);
   int ChartHeight= guiGetChartHeight(hwnd);

   bool TakeScreenShot=ChartScreenShot(0,filename,ChartWidth,ChartHeight,ALIGN_RIGHT);
  }

 

But when I check my files I see this

 

There is no file ext (.gif, jpeg,png). No file ext no picture.  

 

Can someone please help the worlds worst programmer. 

 

P.S. I also ues the coding from the good people at  http://www.mt4gui.com/

 

Fernando Carreiro
1438
Fernando Carreiro 2016.06.27 23:05  
That is because you are using colons in the filename which are invalid characters. A filename such as "2016.06.27 15:24:31.png" is invalid, so you end up with only "2016.06.27 15" because it gets truncated at the first invalid character.
Robert Browne
88
Robert Browne 2016.06.28 09:38  

Thank you so much bro. Got it working a treat now. :)

Here's the new code for others that might find themselves in my shoes.

 

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void TakePicture()
//+------------------------------------------------------------------+
  {
   string filename= "ScreenShot\\"+IntegerToString(TimeYear(TimeCurrent()))+"\\"+Symbol()+"\\"+IntegerToString(TimeMonth(TimeCurrent()))+"\\"+IntegerToString(TimeDay(TimeCurrent()))+"\\"+IntegerToString(TimeHour(TimeCurrent()))+"_"+IntegerToString(TimeMinute(TimeCurrent()))+".png";
   int ChartWidth = guiGetChartWidth(hwnd);
   int ChartHeight= guiGetChartHeight(hwnd);

   bool TakeScreenShot=ChartScreenShot(0,filename,ChartWidth,ChartHeight,ALIGN_RIGHT);
  }
/
To add comments, please log in or register