The new chart (ChartOpen) has no time to be opened yet. Add a Sleep(10) or something.
Forum on trading, automated trading systems and testing trading strategies
Hello,
The new chart (ChartOpen) has no time to be opened yet. Add a Sleep(10) or something.
Ive tried Sleep(5000) after opening chart and it still does not work :(
That code works fine for me... is the chart opening as it should?
That code works fine for me... is the chart opening as it should?
Yes, the chart is opening as it should, btw I think I might know what the problem is ... the code seems to work if I use it on a windows platform but not when I use it on my mac !
dear all, I got the same problem.
With the same function it works well in Script mode and live mode. However in backtest mode I get all empty files.
have you overcome this problem?
I just include this function on ExpertMACD.mql5 and capture chart for every new completed bar:
//+------------------------------------------------------------------+
{
MqlDateTime tm;
TimeToStruct(TimeCurrent(),tm);
string filename= "ChartScreen\\" + IntegerToString(tm.year)
+ "\\"+Symbol()+"\\"+IntegerToString(tm.mon)
+ "\\"+IntegerToString(tm.day)+"\\"+IntegerToString(tm.hour)
+ "_"+IntegerToString(tm.min)+ "." + patternName + ".BMP";
int chartHeight = (int)ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS, 0);
int chartWidth = (int)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS, 0);
bool scCapture=ChartScreenShot(0, filename, chartWidth, chartHeight, ALIGN_RIGHT);
if (scCapture) {
PrintFormat("Take screenshot successful ");
} else {
PrintFormat("Take screenshot failure");
}
}
Yes, the chart is opening as it should, btw I think I might know what the problem is ... the code seems to work if I use it on a windows platform but not when I use it on my mac !
dear all, I got the same problem.
With the same function it works well in Script mode and live mode. However in backtest mode I get all empty files.
have you overcome this problem?
I just include this function on ExpertMACD.mql5 and capture chart for every new completed bar:
//+------------------------------------------------------------------+
{
MqlDateTime tm;
TimeToStruct(TimeCurrent(),tm);
string filename= "ChartScreen\\" + IntegerToString(tm.year)
+ "\\"+Symbol()+"\\"+IntegerToString(tm.mon)
+ "\\"+IntegerToString(tm.day)+"\\"+IntegerToString(tm.hour)
+ "_"+IntegerToString(tm.min)+ "." + patternName + ".BMP";
int chartHeight = (int)ChartGetInteger(0, CHART_HEIGHT_IN_PIXELS, 0);
int chartWidth = (int)ChartGetInteger(0, CHART_WIDTH_IN_PIXELS, 0);
bool scCapture=ChartScreenShot(0, filename, chartWidth, chartHeight, ALIGN_RIGHT);
if (scCapture) {
PrintFormat("Take screenshot successful ");
} else {
PrintFormat("Take screenshot failure");
}
}
During a backtest there is no chart, so the screenshot is empty.
Hi Alain,
I read often your valid comments.
I think the purpose of the post is to take screeshot on historical data, do you know how?
I have the same proble to have empty file while backtesting
Best regards
Marco
Hi Alain,
I read often your valid comments.
I think the purpose of the post is to take screeshot on historical data, do you know how?
I have the same proble to have empty file while backtesting
Best regards
Marco
In Visual mode I suppose it should work, I didn't check though.
Hi Alain,
thanks for your support, however it is not working. I would like to use screeshot of historical charts in order to use algorithms of computer vision but I do not know how to proceed, it is now 3 weekd that I cannot produce images and I do not know how to circumvent the problem. Any suggestion or help?
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
hi there
I am noticing that ChartScreenShot() is saving the files as empty (i.e. zero byte files), anyone noticing a similar result ? ChartScreenShot () function returns true btw and I am using the latest build of 1052.
I am using the following code :
int OnStart(){
long chartid;
chartid=ChartOpen("EURUSD",PERIOD_H1);
string file="picture.gif";
Alert("screenshot =",ChartScreenShot(chartid,file,800,600));
return(0);
}
thanks
wilson