NavigationUser loginWho's new
Who's onlineThere are currently 0 users and 40 guests online.
|
ScreenShot - Part 1Hi folks, Today we are going to study in details a very important MQL4 function; the ScreenShot() function and in the coming article we are going to create a useful expert advisor that ...... Let's start from the beginning and know what screen shots means in MetaTrader? MetaTrader Screen Shot:In MetaTrader it's easy to save any chart you want with all the indicators plotted to it. ![]() This will bring Save As Picture dialog (Figure 2) to choose from it one of three options: 1- Active work space: Choosing this option will save a screen shot with all the MetaTrader program (Toolbar, Menus, Charts and windows). It's very like pressing ALT + Print Screen in Microsoft Window. 2- Active chart (as is): This option will save the chart as it appears in front of you with the same size. 3- Active chart: This option will enable you to set the width and height of the chart you want to save. If you supplied big width, MetaTrader will go through the history of the chart and save it in the picture. When you choose the option you want and click ok you will get a dialog asking you about the name of the image, where to save it and what the type of the image you want to save (Figure 3). You cab choose one of two formats for the save image: GIF format or JPEG format. Saving Screen Shots in MQL4:Saving screen shots in MQL4 is a bit harder than the normal MetaTrader method but the best thing it's automated and very faster than the normal method. ScreenShot:Syntax:
Description: The ScreenShot function is the one responsible of saving the current chart, you pass to the filename of the saved image with the settings parameters which we will know later. You have to know two important things about the ScreenShot function that differentiate it than the normal MetaTrader screen shot: 1- Limited saving folder: While in the normal MetaTrader ScreenShot saving you can choose the folder you want to save the image, the ScreenShot function only uses one of two folders to save the images: A- terminal_dir\experts\files and its sub folders in the case of forward mode. 2- Limited image format: The normal MetaTrader ScreenShot image can be in GIF or JPG format, while the ScreenShot function will save the image in GIF format only. Parameters: string filename: The file name of the image you want to save, don't forget the .gif extension (see the example) Note: You can create sub folder by adding this folder before the file name of the image and separating them by "/" sign (see the example). int size_x: The width of the image in pixels. int size_y: The height of the image in pixels. int start_bar: The first bar you want to include in your image, 0 means the first visible bar on the chart. int chart_scale: The scale (zoom) of the chart, this value range from 0 to 5. int chart_mode: The displaying mode of the chart you want to apply to your saved image; 0 means Bars Chart, 1 means Candle Chart and 2 means Line Chart. Example:
I hope you enjoyed this lesson and promise this will not be the last lesson about the ScreenShot function. In the coming lesson we are going to write a useful piece of code that puts ScreenShot function to use. Coders Guru |