Problem with the delay of ChartSetSymbolPeriod()

 

Hi coders,

the H1 chart is open. Now I would like to have screenshots from H1, M15 and H4. I do it this way:

ChartScreenShot(0, _Symbol+(string)_Period+".png", 1280, 720);
ChartSetSymbolPeriod(0, NULL, PERIOD_H4);
ChartScreenShot(0, _Symbol+(string)_Period+".png", 1280, 720);
ChartSetSymbolPeriod(0, NULL, PERIOD_M15);
ChartScreenShot(0, _Symbol+(string)_Period+".png", 1280, 720);

As you surely know, that doesn't work because ChartSetSymbolPeriod() works asynchronous and doesn't wait for the timeframe to be changed before continuing with the code. So the result is only one screenshot of the current timeframe.

Can someone help me to solve this problem in any other way?

Thanks in advance! 

 
Change the period and return. After the terminal switches, then take the next screenshot.
 

Ok, then I can't do a script with this. If I need to return it then it can only be done with an indicator or EA.

Thanks mate! 

Reason: