Hello everyone.
1. I am trying to attach a template to chart and then take a screenshot.
2. I realized when I use ChartScreenshot too soon the template is not loaded yet and it is not visible in screenshot.
3. I use Sleep function to avoid this.
I am wondering if there is a better solution?
If you're trying to do this from a single MQL program, your logic is wrong. When a user or a program is applying a template, all current programs are unloaded and then the template is loaded causing further loading of other MQL programs, if they mentioned in the template. So "screenshotting" can be bound only to an event (OnInit, OnCalculate, OnTimer) in, say, dummy indicator mentioned in the template.
Hello everyone.
1. I am trying to attach a template to chart and then take a screenshot.
2. I realized when I use ChartScreenshot too soon the template is not loaded yet and it is not visible in screenshot.
3. I use Sleep function to avoid this.
I am wondering if there is a better solution?
Sure there is a better solution, but it depends of your needs and if you want it generic or specific. In general, as Stanislav said, use events, I would just prioritize OnChartEvent rather than the others.
OnChartEvent is not guaranteed ;-) (something should happen with the chart, like click/resize by user), which is why I suggested OnInit (will be called surely) and OnTimer (will be called if requested in OnInit), also OnCalculate is guaranteed at list once.
OnChartEvent is not guaranteed ;-) (something should happen with the chart, like click by user), which is why I suggested OnInit (will be called surely) and OnTimer (will be called if requested in OnInit), also OnCalculate is guaranteed at list once.
What is not guaranteed exactly ? "something should happen with the chart, like click by user" : not at all.
Anyway, if you want to use other events, it's fine for me.
What is not guaranteed exactly ? "something should happen with the chart, like click by user" : not at all.
Anyway, if you want to use other events, it's fine for me.
I suggested guaranteed event types, not because I want them. OnChartEvent can happen not to fire at all in the newly loaded "screenshotting" program, unless additional actions are taken by user or by other programs.
Thanks for the replies. Let me clarify something.
This is the procedure:
1. Open another chart (ChartOpen)
2. Apply template to it.
3. Take screenshot of it.
It is not meant to take screenshot of the current chart that has the EA running.
Thanks for the replies. Let me clarify something.
This is the procedure:
1. Open another chart (ChartOpen)
2. Apply template to it.
3. Take screenshot of it.
It is not meant to take screenshot of the current chart that has the EA running.
And what is on this template ?
The best solution is to have some code running on this new chart that will notify the "running EA" of the other chart, or possibly to take the screenshot itself.

- 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.
1. I am trying to attach a template to chart and then take a screenshot.
2. I realized when I use ChartScreenshot too soon the template is not loaded yet and it is not visible in screenshot.
3. I use Sleep function to avoid this.
I am wondering if there is a better solution?