Timer - page 4

 

To have a range of OnTimer events of less than a second.

And to be able to measure some processes in milliseconds.

I didn't understand the idea with "...(int delay=0)" at all, that's why I wrote it as bullshit.

 
Yedelkin:
As you have understood, 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 the delay of generation of the first Timer event on the terminal level for the time chosen by a user. I'm not belittling the importance of your code, especially as I simply haven't seen it.

How do you envisage organising the first event delay from the timer?

The same second timer will be started in the terminal and timer events will be generated for the Expert Advisor at a certain moment. Everything is exactly the same as I have already suggested.

 
stringo:

How do you envisage organising the first event delay from the timer?

The same second timer would be started in the terminal and at a certain point the timer events would start to be generated for the Expert Advisor. Everything is absolutely the same as I have already suggested.

That's how I imagine it. Having found the EventSetTimer(14400, 7029) function in OnInit() , the terminal will activate internal timer and generate the first Timer event exactly at 7029 seconds after program start (say, at 12-00), as the user wishes. Further Timer events will be generated at intervals of once every four hours. One event per 4 hours, not 14400 events, where 13399 Timer events are meaningless to the user.

This approach, in my opinion, is radically different from the one you suggest. Because in my variant the internal second timer (counting 7029 seconds) will work for a limited time only after initialization of the Expert Advisor, and will stop its work without clogging up the event queue. Your variant provides continuous generation of every second events, from the first to the last minute of expert's work, of which only every 14400th event will have at least some weight for a user.
 
pusheax:

To have a range of OnTimer events of less than a second.

And to be able to measure some processes in milliseconds.

Actually current parameter"int seconds// number of seconds" defines periodicity of timer events, not some "delays for OnTimer". Learn the math. Regarding milliseconds, at least read the first page of the thread to begin with.

pusheax:

I didn't understand the idea with "...(int delay=0)" at all and that's why I wrote that it was rubbish.


I see. It's a bit of a "just sayin' before you know it" kind of thing. That's OK, it happens :) We all sometimes want to share our vision of beauty with others.

 
Yedelkin:

That's how I see it. Having found the EventSetTimer(14400, 7029) function in OnInit() , the terminal will activate the internal second timer and generate the first Timer event exactly 7029 seconds after program start (say, at 12-00), as the user wishes. Further Timer events will be generated at intervals of once every four hours. One event per 4 hours, not 14400 events, where 13399 Timer events are meaningless to the user.

This approach, I think, is radically different from what you suggested. Because in my variant the internal second timer (counting 7029 seconds) will work for a limited time only after EA's initialization, and will stop working, without clogging up the event queue. Your variant provides continuous generation of every second events, from the first to the last minute of expert's work, of which only every 14400th event will have at least some weight for a user.

Ok

In function OnInit start timer EventSetTimer(7029);

In the OnTimer function at the first arrival disable the previous EventKillTimer() timer and start a new timer EventSetTimer(1440);

 
stringo:

In the OnTimer function on first arrival, disable the previous EventKillTimer() timer and start a new timer EventSetTimer(1440);

Will it work properly? Someone said not too long ago that the EventSetTimer function is essentially for a one-time call from the init.
 
stringo:

Ok

In OnInit function start timer EventSetTimer(7029);

In OnTimer function on first come, disable previous timer EventKillTimer() and start new timer EventSetTimer(1440);

Oh, the light at the end of the tunnel! Call EventSetTimer() inside the OnTimer() itself? I'll definitely try it when I get to the terminal. Thanks for the smart solution!
 
TheXpert:
Will it work properly? Someone said not too long ago that the EventSetTimer function is essentially meant to be called once from the init.
I did. This is a common application. Which doesn't at all invalidate the exotics (if you feel like it).
 
stringo:

Ok

In OnInit function start timer EventSetTimer(7029);

In OnTimer function on first come, disable previous timer EventKillTimer() and start new timer EventSetTimer(1440);

That's how I' ve been doing it since ancient times. However, in the tester this approach didn't work for a while. Switched to counters in the tester.

But it's all lyric. Milliseconds are very desirable. I join in the wishes.

Now I need 100 ms time resolution, but I have such an urge now and don't know what I will need tomorrow. I wouldn't like to have such a high bitrate threshold, 1000 ms is too thick. Milliseconds is standard. If someone foolishly overflows the queue - it's his tragedy (there are always many very affordable ways to crash the program with the terminal as well). We'll figure out what we can and can't do sometime :)

 

It is no longer possible to go to milliseconds.

How many EAs already written will start generating 1000 times more timer events than the author intended?