MQL5 ScreenShot() method

 

Hi,


I tried using the following method for taking chart screenshots, but it's not working, I have searched the MQL5 folder for any pictures of the screenshots and I haven't found anything.

https://www.mql5.com/en/docs/standardlibrary/cchart/cchartscreenshot

Bellow there is a code snipped of the function I'm calling inside the OnTick() loop

#include <Charts\Chart.mqh>
Cchart chart;

OnTick()
	{
	}

void OnTradeTransaction(const MqlTradeTransaction & trans,
                        const MqlTradeRequest & request,
                        const MqlTradeResult & result)
  {
	takeScreenShot();
  }

void takeScreenShot()
  {
   string name="ScreenShot"+GetTickCount()+".gif"; //using GetTickCount to generate unique screenshot names everytime
   ChartNavigate(0,CHART_END,0);
   chart.ScreenShot(name,1000,600,ALIGN_RIGHT);
  }


I guess there must be restrictions on how to use it.


Also tried using the ChartScreenShot() in a similar fashion but it can't be called inside OnTick() (only works inside OnChartEvent() ) for some unknown reason...... maybe it applies also to chart.ScreenShot()


I wanted to take screenshots everytime I enter and exit a trade, I don't have clue how to do it inside the OnChartEvent() since it requires interaction with the chart.


Thanks in advance.

Documentation on MQL5: Standard Library / Price Charts / ScreenShot
Documentation on MQL5: Standard Library / Price Charts / ScreenShot
  • www.mql5.com
ScreenShot(string,int,int,ENUM_ALIGN_MODE) - Price Charts - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Anyone?
 
At least the right point in time would be using OnTrade() handler.

Do you get an Error code when using GetLastError()?
 
Dominik Egert:
At least the right point in time would be using OnTrade() handler.

Do you get an Error code when using GetLastError()?

Sorry for the delay, GetLastError() is returning "0".....

 

The first parameter isn't a filename, it's a chart ID.

By the way, I cannot take a screenshot except the current chart.