Check the directory ... \tester\files\
There is no such director available.
There is no such director available.
It is EA instead of script,the correct codes as below.
Test it on chart, and click the chart, the screenshot is saved in MQL5\Files
#property description "The Expert Advisor demonstrates how to create a series of screenshots of the current" #property description "chart using the ChartScreenShot() function. For convenience, the file name is" #property description "shown on the chart. The height and width of images is defined through macros." #define WIDTH 800 // Image width to call ChartScreenShot() #define HEIGHT 600 // Image height to call ChartScreenShot() //--- input parameters input int pictures=5; // The number of images in the series int mode=-1; // -1 denotes a shift to the right edge of the chart, 1 - to the left int bars_shift=300;// The number of bars when scrolling the chart using ChartNavigate() //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- Disable chart autoscroll ChartSetInteger(0,CHART_AUTOSCROLL,false); //--- Set the shift of the right edge of the chart ChartSetInteger(0,CHART_SHIFT,true); //--- Show a candlestick chart ChartSetInteger(0,CHART_MODE,CHART_CANDLES); //--- Print("Preparation of the Expert Advisor is completed"); } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- Show the name of the function, call time and event identifier Print(__FUNCTION__,TimeCurrent()," id=",id," mode=",mode); //--- Handle the CHARTEVENT_CLICK event ("A mouse click on the chart") if(id==CHARTEVENT_CLICK) { //--- Initial shift from the chart edge int pos=0; //--- Operation with the left chart edge if(mode>0) { //--- Scroll the chart to the left edge ChartNavigate(0,CHART_BEGIN,pos); for(int i=0;i<pictures;i++) { //--- Prepare a text to show on the chart and a file name string name="ChartScreenShot"+"CHART_BEGIN"+string(pos)+".gif"; //--- 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_LEFT)) Print("We've saved the screenshot ",name); //--- pos+=bars_shift; //--- Give the user time to look at the new part of the chart Sleep(3000); //--- Scroll the chart from the current position bars_shift bars to the right ChartNavigate(0,CHART_CURRENT_POS,bars_shift); } //--- Change the mode to the opposite mode*=-1; } else // Operation with the right chart edge { //--- Scroll the chart to the right edge ChartNavigate(0,CHART_END,pos); for(int i=0;i<pictures;i++) { //--- Prepare a text to show on the chart and a file name string name="ChartScreenShot"+"CHART_END"+string(pos)+".gif"; //--- 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); //--- pos+=bars_shift; //--- Give the user time to look at the new part of the chart Sleep(3000); //--- Scroll the chart from the current position bars_shift bars to the right ChartNavigate(0,CHART_CURRENT_POS,-bars_shift); } //--- Change the mode to the opposite mode*=-1; } } // End of CHARTEVENT_CLICK event handling //--- End of the OnChartEvent() handler }
It is EA instead of script,the correct codes as below.
Test it on chart, and click the chart, the screenshot is saved in MQL5\Files
I know this code. But I want to take snapshot of every tick. Hence, I have placed the code in the OnTick().
Can you help me get the snapshot of every tick?
I know this code. But I want to take snapshot of every tick. Hence, I have placed the code in the OnTick().
Can you help me get the snapshot of every tick?
Just for your reference.
#property description "The Expert Advisor demonstrates how to create a series of screenshots of the current" #property description "chart using the ChartScreenShot() function. For convenience, the file name is" #property description "shown on the chart. The height and width of images is defined through macros." #define WIDTH 800 // Image width to call ChartScreenShot() #define HEIGHT 600 // Image height to call ChartScreenShot() //--- input parameters input int pictures=5; // The number of images in the series int mode=-1; // -1 denotes a shift to the right edge of the chart, 1 - to the left int bars_shift=300;// The number of bars when scrolling the chart using ChartNavigate() //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- Disable chart autoscroll ChartSetInteger(0,CHART_AUTOSCROLL,false); //--- Set the shift of the right edge of the chart ChartSetInteger(0,CHART_SHIFT,true); //--- Show a candlestick chart ChartSetInteger(0,CHART_MODE,CHART_CANDLES); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- //--- Initial shift from the chart edge int pos=0; //--- Operation with the left chart edge if(mode>0) { //--- Scroll the chart to the left edge ChartNavigate(0,CHART_BEGIN,pos); for(int i=0;i<pictures;i++) { //--- Prepare a text to show on the chart and a file name string name="ChartScreenShot"+"CHART_BEGIN"+string(pos)+".gif"; //--- 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_LEFT)) Print("We've saved the screenshot ",name); //--- pos+=bars_shift; //--- Give the user time to look at the new part of the chart Sleep(3000); //--- Scroll the chart from the current position bars_shift bars to the right ChartNavigate(0,CHART_CURRENT_POS,bars_shift); } //--- Change the mode to the opposite mode*=-1; } else // Operation with the right chart edge { //--- Scroll the chart to the right edge ChartNavigate(0,CHART_END,pos); for(int i=0;i<pictures;i++) { //--- Prepare a text to show on the chart and a file name string name="ChartScreenShot"+"CHART_END"+string(pos)+".gif"; //--- 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); //--- pos+=bars_shift; //--- Give the user time to look at the new part of the chart Sleep(3000); //--- Scroll the chart from the current position bars_shift bars to the right ChartNavigate(0,CHART_CURRENT_POS,-bars_shift); } //--- Change the mode to the opposite mode*=-1; } } //+------------------------------------------------------------------+ //| ChartEvent function | //+------------------------------------------------------------------+ void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) { //--- } //+------------------------------------------------------------------+
Just for your reference.
So does that means that I cannot take screenshot of the chart using OnTick() function?
Because I will apply certain conditions and take snapshot so that my expert work properly I can see. As I am trying to use the years of data for my operation. Hence, it is quite tedious to move back many times just to look whether the expert adviser working properly or not.
Kindly, let me know.
Just for your reference.
The code is not saving the images anywhere in the system. The output log shows We've saved the screenshot. But there is nothing in the \Files folder. Please let me know why is it so/ Help me improve the code please.
The code is not saving the images anywhere in the system. The output log shows We've saved the screenshot. But there is nothing in the \Files folder. Please let me know why is it so/ Help me improve the code please.
Go through the menu File-->Open Data Folder, or just search for the file.
There is a quick search app
So does that means that I cannot take screenshot of the chart using OnTick() function?
Because I will apply certain conditions and take snapshot so that my expert work properly I can see. As I am trying to use the years of data for my operation. Hence, it is quite tedious to move back many times just to look whether the expert adviser working properly or not.
Kindly, let me know.
You can do it in OnTick(), call ChartScreenShot(0,name,WIDTH,HEIGHT,ALIGN_RIGHT) in your EA code.
You can do it in OnTick(), call ChartScreenShot(0,name,WIDTH,HEIGHT,ALIGN_RIGHT) in your EA code.
I tried t. But I could not see the things, please help me. Did you got the sceenshots in your file folder or any data folder? PLease share.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone,
I am trying to take the snapshot of the chart while I am testing. But the script is not at all working. I could not see anything in the \Files folder. Please help me. Here is the script: