Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1509
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
While I've been away .........
At first glance it seems fine. You can check it in the script any day. But here in the documentation I don't like the example. Here is how I advise to write
For such a task
Why? Because it is so nice to live without a cycle on every tick.
I need it on every tick, because I found an object to buy-bought, found an object to sell-sold
Yes I get it, and when the event arrives, we know instantly that the object has been created. Even before the first closest tick, and without a loop. That's the idea. We just sit and wait.
This simple example shows how we can monitor object creation on the current chart. If you get twisted, you can keep track of the other charts you want.
Cost of processor effort: zero.
Why? It's so nice to live without loops on every tick.
Because the indicator cannot make trades.
I am not against OnChartEvent, but it works only on its own chart and then we will have to put the EA on every chart, and Makar wants the EA to be on only one chart.
Aleksei Stepanenko:
... If you have a twist, you can watch the other charts you need.
Cost of Effort of the Processor: Zero.
Because the indicator cannot make trades.
I'm not against OnChartEvent, but it only works on its own chart and then you would have to put the EA on every chart, and Makar wants the EA to be on only one chart.
https://www.mql5.com/ru/forum/369209
https://www.mql5.com/ru/forum/369209
With OnChartEvent not otherwise.
Thanks, it works perfectly!
Shove the code that Alexey gave you into the Timer with an interval of a couple of seconds. Also add a line that if market is closed- exit, so as not to run the cycle.
This approach will relieve CPU load in fast market, and in slow market it will allow to track object appearance on another chart faster.