Download MetaTrader 5

Is Access to Global Variables Thread-Safe?

To add comments, please log in or register
simha
144
simha  

Hello,

 

Terminal global variables are available for concurrent access from all running EAs. Each EA runs on its own thread (as stated on official documentation).

Is access (Read/Write) to global variables assured to be race-condition-free?

 

More Generally: Can the MT4 terminal start processing a tick of symbol B, while a previous tick of symbol A is being processed?

 

Thanks much. 

whroeder1
15304
whroeder1  
Simha:
Is access (Read/Write) to global variables assured to be race-condition-free?
More Generally: Can the MT4 terminal start processing a tick of symbol B, while a previous tick of symbol A is being processed?
  1. Only OnCondition could be, which I used it to write a mutex.
  2. Yes. That is exactly what "Each EA runs on its own thread" means.
Carl Schreiber
6968
Carl Schreiber  

The GlobalVariables have a time stamp of the last access: GlobalVariableTime("name") which seems to be the local (pc) time (not TimeCurrent()) and is accurate to the nearest second.





simha
144
simha  
WHRoeder:
  1. Only OnCondition could be, which I used it to write a mutex.
  2. Yes. That is exactly what "Each EA runs on its own thread" means.

Thanks for the useful answer.

simha
144
simha  
gooly:

The GlobalVariables have a time stamp of the last access: GlobalVariableTime("name") which seems to be the local (pc) time (not TimeCurrent()) and is accurate to the nearest second. 

Thanks. I've found this useful.

To add comments, please log in or register