Timer

 

Actually, the question is, why is the timer measured in seconds?

Honestly, when I heard that there would be a native timer, I had no idea that the atomic unit of time would be a second instead of a millisecond...

Not a very pleasant (for me) discovery I made recently, when I wanted to use it.


The premise is very simple -- the timer is usually used for synchronization (waiting for the data to be calculated) or observation (a timed EA, imho, will be much more adequate). In both cases, a second is a bit much, but we'd really like to see milliseconds in the timer.

Again, it is a good replacement for the Sleep function in the indices and a second is too much.

I hope the developers will consider this request. If necessary, I will make a request in the Service Desk.

I have opened this topic for discussion. What do you think?

Общайтесь с разработчиками через Сервисдеск!
Общайтесь с разработчиками через Сервисдеск!
  • www.mql5.com
Ваше сообщение сразу станет доступно нашим отделам тестирования, технической поддержки и разработчикам торговой платформы.
 
TheXpert:

Actually, the question is, why is the timer measured in seconds?

Honestly, when I heard that there would be a native timer, I had no idea that the atomic unit of time would be a second instead of a millisecond...

Not a very pleasant (for me) discovery I made recently, when I wanted to use it.


The premise is very simple -- the timer is usually used for synchronization (waiting for the data to be calculated) or observation (a timed EA, imho, will be much more adequate). In both cases, a second is a bit much, but we'd really like to see milliseconds in the timer.

Again, it is an excellent substitute for the Sleep function in the indices, and again the second is too much.

I hope, the developers will not ignore this request. If necessary, I will make a request in Service Desk.

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

You can believe me, the current realization of the trading terminal and the algorithm of working with threads in MQ seconds is a good solution.

The more so that the time in the tester is generated on the basis of the minute chart (as far as I understood) and therefore a smaller time scale will not work.

PS

Of course, the developers could give a more detailed answer, but it is enough to understand that the current algorithm of working with threads in Expert Advisor and in the terminal, the time interval shorter than a second is either not possible at all or will simply cause inconsistency in the EA's operation.

To imagine the consequences of such a solution, you need to understand what will happen to the Expert Advisor if its timer is called every 500 milliseconds, while the processing of the timer, for example, takes a minute....

 

Interesting:

Especially as the time in the tester is generated based on the minute chart (as I understand it) and therefore a smaller time scale just won't do.

What does the tester have to do with it?

... A time interval shorter than a second is either not possible at all or will simply cause inconsistency in the Expert Advisor's work.

In what way? Why is it not possible?

To imagine the consequences of such a solution, you need to understand what would happen to the Expert Advisor if its timer is called every 500 milliseconds, while processing timer, for example, takes a minute....

And what will happen? And how much scarier is it if the timer is 1s?

Do you have your head on at all when you write comments?
 
TheXpert:

Actually, the question is, why is the timer measured in seconds?

Honestly, when I heard that there would be a native timer, I had no idea that the atomic unit of time would be a second instead of a millisecond...

Not a very pleasant (for me) discovery I made recently, when I wanted to use it.


The premise is very simple -- the timer is usually used for synchronization (waiting for the data to be calculated) or observation (a timed EA, imho, will be much more adequate). In both cases, a second is a bit much, but we'd really like to see milliseconds in the timer.

And again, it is a good substitute for the Sleep function in the indices and a second is too much.

I hope the developers won't let the request go unheeded. If necessary, I will make a request in servicedesk.

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

The timer in seconds is our conscious decision. The timer is intended mainly for Expert Advisors to work without ticks.

If you want synchronisation, use several Expert Advisors on different instruments that send each other custom messages.

Or write a kind of wotchdog, looped, for example, on a 50 millisecond slip, which sends messages to your main Expert Advisor when expected events occur. In doing so, the messages will be guaranteed to be delivered (unless of course you overflow the queue).

 
stringo:

The timer in seconds is our conscious decision. The timer is primarily intended to allow the experts to work in the absence of ticks.

This can be done without a timer and, by the way, even without the hassle of sending an event to itself. So why not extend the functionality?

If you want synchronisation, use several EAs on different tools that send each other custom messages.

Synchronisation can be with data. For example -- a built-in indicator. How to solve this synchronization in the indicator? I'm not asking about Expert Advisors, everything is solved there without any problems. But in an indicator, Sleep is a standstill of the whole thread, and it means the rest of the indicators. And it means that there is a lot of troubles with synchronization.

You can also write a sort of watchdog loops for 50 msec slip, that sends messages to your main Expert Advisor when expected events occur. The messages will be guaranteed to be delivered (unless you overflow the queue, of course).

Will have to, if nothing changes...
 
TheXpert:

What does this have to do with the tester?

In what way? Why isn't it possible?

And what would happen? And how much scarier is it if the timer is 1s?

Do you use your head when you write comments?

I think that if you know about atomic time units, you probably know about how processes and threads are organized in the OS and the rest of the software.

But just to remind you (just in case there are those who don't know) the basics - Everything that happens in the system is divided into processes and threads, each process can have from one thread to several. Roughly speaking every executable file running in the system is a PROCESS. Each process has a priority, and each thread in a process has a priority.

Based on these priorities system allocates processor time to each process (or thread of a certain process).

So, the architecture of the client terminal is such that only one Expert Advisor and several indicators can be launched on each chart (as you know). The Expert Advisor has a single thread, but each indicator gets its own thread (completely independent) from the Expert Advisor.

It will be fine, but the Expert Advisor or the indicator itself can run only in its thread, i.e. any code line takes the whole thread and no other actions are possible in that thread (of course, there are doubts concerning the processing of ticks, but most probably, they fit into the general pattern).

In this case, for each chart, a separate thread of events is formed which is sequentially processed by the system.

Therefore the timer processing can not be called until the previous timer processing is finished. Or, simply put, OnTimer() will not be allowed to execute until the thread which should process the timer is busy.

To illustrate impossibility of start of timer processing by second thread you can use this example (dumb but clear):

int OnInit()
{
//----------------------------------------------------------------------------//
//Work variables
//----------------------------------------------------------------------------//
EventSetTimer(1);
//----------------------------------------------------------------------------//
return(0);
//----------------------------------------------------------------------------//
}

void OnTimer()
{
//----------------------------------------------------------------------------//
//Work variables
//----------------------------------------------------------------------------//
Print(TimeLocal());
Sleep(2000);
//----------------------------------------------------------------------------//
}

PS

About the strategy tester - how do you propose to form the time there?

 

Interesting:

The architecture of the client terminal is such that only one Expert Advisor and several indicators can be started on each chart (as you know). The Expert Advisor has a single thread, but each indicator gets its own thread (completely independent) from the Expert Advisor.

Since when? I do not see any problems with scripts and Expert Advisors at all, since they work in their own threads.

The indicators ALL work in ONE thread, as you know, and it complicates the task of organizing the timer in any indicator. And sometimes I would like it very much.

The example below shows how the timer cannot be started by a second thread (it is a blunt but illustrative example):

Here is a working example. Bluntly and clearly shows the level of your thinking, especially in the context of the previous post too.

Please do not reply to my posts at all ever again, otherwise I won't be able to restrain myself and will call you bad names and get a ban.

However, if you want, feel free to write, I'll be glad to make fun of you on any programming-related topic, the hell with the ban.

As for the strategy tester, how do you suggest forming the time there?
I am not, I am fine with it so far.
 
TheXpert:

Since when? I don't see a problem with scripts and EAs at all, as they all work in their own threads.

And the indicators ALL work in ONE thread, let it be known, and it complicates the task of organizing the timer in any indicator. And sometimes you really want to.


I wanted not to answer, but I couldn't help myself.

Scripts do not interest me, while I am not sure where I said that Expert Advisors do not run in separate threads (each in its own thread). Here, point me to the place where I said the opposite ....

I am not sure about indicators, because I don't work with them much (surely this question was discussed in forums, and if something happens, the developers will correct it). I know for sure that for each indicator it is possible to prescribe its timer (not depending on the expert), I have already used this possibility.

I know exactly what I should have said about the indices.

TheXpert:

The example works. Bluntly and clearly shows the level of your thinking, especially in the context of the previous post too.

And who would doubt that it works, but the timer (what a bitch) is running every 2 seconds instead of the declared 1, which I pointed in the initialization block.

Especially for you, I put it in an Expert Advisor, although the problem with the timer call was obvious anyway (let's assume that for clarity, they say that in pictures everything is more convenient and easier to understand)...

Now I only need to find out, how OnTimer will be called every 500 milliseconds, if OnTime takes 1 second (in the example a second and two seconds respectively)?

TheXpert:

Please, don't reply to my posts ever again, otherwise I won't be able to restrain myself and will call you bad names and get a ban.

However, if you'd like, feel free to write, I'll be happy to post on any programming-related topic, the hell with it, the ban.

Yes please, I don't have to answer...
 
Only in an argument one can know the truth and in case of adequacy of both arguers one will stick to his opinion (right) and the second will change his opinion (wrong) to the opinion of the first.

So don't tell the other person what he or she is wrong about, or just write: "you are wrong, look it up on google".

As far as I understand the forum - a mutually beneficial conversation, if you have questions only to the developer go to servicedesk.

To Interesting

I've done some experiments with MQL5 performance. Let me tell you: most Expert Advisors perform the OnTick function in less than 0.1 second.


To TheXpert

Why are you in such a hurry?
But I don't see the sense in timer less than a second. Are we counting when two electrons collide?
If so, go ahead with the loop and Sleep().

 

mrProF:

To Interesting

I've been doing some experiments with MQL5 performance, and let me tell you: most EAs perform the OnTick function in less than 0.1 second.

It depends on what to put there and how much data to process, but MQL5 is pretty fast, I'm not disputing that...
 

Another one... Aren't you guys brothers by any chance?

mrProF:

But I don't see the point in a timer of less than a second.

Which doesn't mean there isn't one. Everyone's tasks are different.

If so, go ahead with the loop and Sleep().

Here we go... Can we read? Show me how to do it for the turkeys.
Reason: