Download MetaTrader 5
To add comments, please log in or register
Add our Facebook page to friends. Follow the latest news!
Stuart Browne
5780
Stuart Browne 2016.03.24 08:06 
Hi All

This is very very hard to test and I can't seem to find any documentation on it.

I'm wondering if ChartEvents are queued (synchronous) or are asynchronous? For example, lets say I have two indicators which are sending custom chart events to a third indicator. If the first 2 indicators send a custom event to the 3rd chart at exactly, or nearly exactly the same time, what happens when the 3rd indicator attempts to process the events? Will it process the first event, then have the 2nd event waiting in the queue to process? Or will the 2nd event have disappeared during the time it takes to process the first event? Just like you can miss a Tick if still processing OnTick when the 2nd tick arrives.

Any ideas or documentation that anyone knows of?

Cheers
Stu
Alain Verleyen
Moderator
30635
Alain Verleyen 2016.03.24 10:31  

It's on this page :

Similarly, if ChartEvent is already enqueued, or this event is being processed, no new event of this kind is enqueued.

Stuart Browne
5780
Stuart Browne 2016.03.24 10:51  
Alain Verleyen:

It's on this page :

Champion, thanks Alain :) Looks like I'll need to set an acknowledge message and resend if not acknowledged 
Ex Ovo Omnia
3109
Ex Ovo Omnia 2016.03.24 11:43  
Stuart Browne:
Champion, thanks Alain :) Looks like I'll need to set an acknowledge message and resend if not acknowledged 
If you talk about firing custom events rather than the UI chart events, then they seem to be executed immediately, i.e. like calling a function. So you probably do not need any handshake.
Alain Verleyen
Moderator
30635
Alain Verleyen 2016.03.24 11:55  
Ovo Cz:
If you talk about firing custom events rather than the UI chart events, then they seem to be executed immediately, i.e. like calling a function. So you probably do not need any handshake.
The custom event can only be executed immediately if it's the same thread. So it depends of the usage.
Stuart Browne
5780
Stuart Browne 2016.03.24 15:27  
Thanks guys. Yeah my problem arises as I could have up to 5 charts firing custom events to one chart at the same time, so there is a chance, however slight, that 2 could collide and I'd miss one. So I think a handshake would be the safest, though a lot more coding
Ex Ovo Omnia
3109
Ex Ovo Omnia 2016.03.24 19:19  
Stuart Browne:
Thanks guys. Yeah my problem arises as I could have up to 5 charts firing custom events to one chart at the same time, so there is a chance, however slight, that 2 could collide and I'd miss one. So I think a handshake would be the safest, though a lot more coding
In the thread above you talked about indicators, and they run in a single thread. But you may still use the handshake to ensure the other party is listening.
Alain Verleyen
Moderator
30635
Alain Verleyen 2016.03.24 19:39  
Ovo Cz:
In the thread above you talked about indicators, and they run in a single thread. But you may still use the handshake to ensure the other party is listening.

Not all indicators are running in the same thread, only if it's the same symbol.

EDIT: It's for MT5, seems it's different for MT4, so you are probably right.

Program Running - MQL4 programs - MQL4 Reference
Program Running - MQL4 programs - MQL4 Reference
  • docs.mql4.com
Program Running - MQL4 programs - MQL4 Reference
Stuart Browne
5780
Stuart Browne 2016.03.25 02:16  
Ovo Cz:
In the thread above you talked about indicators, and they run in a single thread. But you may still use the handshake to ensure the other party is listening.
Yeah sorry, my fault, bad example. They're actually EAs so are running in separate threads. I think I've decided to go with using the custom events to fire the message and globals to ack.
/
To add comments, please log in or register