Need some Advice regarding limiting the server calls from the EA.

 
Hello All 
I am seeking some advice from more experienced members of this community 

Basically I am working on a Socket client EA which connects to a remote Socket server and get some calculated values from the server , after receiving those values I am saving these values into a text file and processing the values further. Server is sending the data for all currency pairs , so even if client is running only on one chart its still receiving the data for all pairs. 

but the problem is let say user opens 24 charts and attaches the EA to all of the charts now EA will try and connect to the server from all charts , and also will try and save the data to the text file, which isn't really necessary since only one instance can connect and receive all the necessary information from the server

What will be the best approach to let the other instances of the EA know that one instance is already connected to the server and is retrieving the necessary data from the server ?

I am not looking for the code , just need some theoretical information.

Any and all help will be highly appreciated 

thank you  
 
Arman: all of the charts now EA will try and connect to the server from all charts ,

EAs do not connect to any server. The terminal has connected to the server and requests data for all open charts. After the initial update, only changes (ticks) are sent.

There are no unnecessary data from the server. You are over thinking it.

 
William Roeder #:

EAs do not connect to any server. The terminal has connected to the server and requests data for all open charts. After the initial update, only changes (ticks) are sent.

There are no unnecessary data from the server. You are over thinking it.

Sorry William , I think I didnt Explained the Question in a better way 

What I meant was : 
The Ea is connecting to a remote Socket server , and the server Is sending some values which is necessary to open trade , these values are the result of calculation which the server is performing and then the client EA execute trades based on those values.

Now let say  EA is attached to EURUSD , its receiving the values for all the pairs and then saving it into a text file in the Files directory , which means if the EA Is attached to other pairs , it is not necessary to connect to the socket server again , it can just read the previously received values 
so if there EA from one chart is already connected to the socket server , then what will be the best approach to avoid EAs on other charts to not connect to the socket server ?

 
Build a mutual exclusive object by utilizing Terminal Global Variables.

You can find good data on semaphores, interlocks and atomic operations combined with the term c++ in Google.

You will need a type of variable name as unique, common identifier and a uID (Unix timestamp in microseconds should be sufficient) for your session recognition. This way you can identify the role of the read/write agent and leave all other in "slave" mode, being only readers.

I guess you get the concept.

You will need a type of clearing function for your global variable, as it can be, if your EA crashes, and you couldn't remove the "semaphore", you need some kind of cleanup process and idea...
 
Dominik Egert #:
Build a mutual exclusive object by utilizing Terminal Global Variables.

You can find good data on semaphores, interlocks and atomic operations combined with the term c++ in Google.

You will need a type of variable name as unique, common identifier and a uID (Unix timestamp in microseconds should be sufficient) for your session recognition. This way you can identify the role of the read/write agent and leave all other in "slave" mode, being only readers.

I guess you get the concept.

You will need a type of clearing function for your global variable, as it can be, if your EA crashes, and you couldn't remove the "semaphore", you need some kind of cleanup process and idea...
An easier alternative would be for the EA to have an input variable declaring it master/slave where the slave would never connect to the server.