Timer - page 3

 
TheXpert:

Using the timer manager. I wanted to write an article, but then it got sidetracked. Although it may not be enough for an article.

You won't get it in a specific time because of single-threaded code and event queue, but with an average error less than a second (maximum is limited by the maximum time of event execution by the code).

The more so, there is only one timer.

Do you need it?

Yes, the margin of error is almost imperceptible. Maybe you want to upload it to Code Base at once? It will get lost on the forum, and someone else will need it there.
 
Yedelkin:
Yes, the error is almost imperceptible. Why don't you put it in Code Base at once? It'll get lost on the forum, and someone else will need it.

Not quite finished, I'm busy with my File Unlimited for 5. I'll be finished soon.

The point is not about whether we'll need it or not. It's the only normal and correct way to work with multiple timers.

 
TheXpert:

Not quite finished, I'm busy with my File Unlimited for 5. I'll be finished soon.

That's okay, we'll wait. I'll contact SD, maybe they'll make it possible to start the first Timer event with a certain delay.
Документация по MQL5: Программы MQL5 / События клиентского терминала
Документация по MQL5: Программы MQL5 / События клиентского терминала
  • www.mql5.com
Программы MQL5 / События клиентского терминала - Документация по MQL5
 
Yedelkin:

Is there any way to get the EA to generate Timer events at a specific time? For example, at the start of the last minute of the hour or the day.

What's the problem? Run a normal timer and analyse the time. If it doesn't fit the time, leave OnTimer right away.
 
TheXpert:

Again, this is a great substitute for the Sleep function in the turkeys, and again, a second is a bit much.

The topic is open for discussion. What do you think?

There is one nuance. The timer in the indicator doesn't work if it's not attached to the chart. Therefore, even a second timer is often useless in indicators.

Here is a solution for monitoring events of less than one second. Perhaps, a timer can be done in conjunction with GetTickCount().

 
stringo:
What is the problem? You need to run normal timer and analyze the time. If time is not suitable - exit OnTimer at once.

And why should I bombard the queue with every second Timer events and waste my time on checking OnTimer() every second, if I want to run OnTimer() once per day (per hour etc.) but at a certain time?

I believe that it would be much more rational and elegant to use this function with two parameters:

   bool EventSetTimer(
                   int seconds,      // количество секунд для OnTimer
                   int задержка=0     // количество секунд задержки запуска первого события Timer 
                   );

Which is what the SD suggested.

Addition: the value of the delay parameter can be easily and once calculated in OnInit().

 
Yedelkin:

And why...

Well, actually, that's what I was suggesting. Just wrapped up in a convenient package.

Once a second is a scary pittance, especially if you skip unnecessary events.

 
You just need to convert the delay in seconds to milliseconds.
bool EventSetTimer(1000);// количество миллисекунд для 1 секунды задержки для OnTimer

and this.

int задержка=0     // количество секунд задержки запуска первого события Timer 

not to do it at all, as it's just bullshit.

 
pusheax:

int задержка=0     // количество секунд задержки запуска первого события Timer 

not to do it at all, as it's just bullshit.

I'll ask as a bullshit expert. What is the idea behind this delay(int delay=0), and for what purpose was it (delay) suggested? How did you understand it?

And second question I want to clarify, what is the point of specifying"number of milliseconds for 1 second delay for OnTimer"? What goal are you trying to achieve? For example, to delay every second in OnTimer by three milliseconds?

 
TheXpert:

Well, that's actually what I was suggesting. Just wrapped up in a convenient package.

Once per second is a scary pittance, especially if you skip unnecessary events.

As you understand, in this case, my motto is: "Down with all misers if you can do without them". The only thing you need to do is to allow delay of generation of the first Timer event on the terminal level for the time chosen by a user. Thus, I'm not belittling the importance of your code, especially since I simply haven't seen it.
Документация по MQL5: Программы MQL5 / События клиентского терминала
Документация по MQL5: Программы MQL5 / События клиентского терминала
  • www.mql5.com
Программы MQL5 / События клиентского терминала - Документация по MQL5
Reason: