Communication between two EAs

Hi all

Is there a way for the active EAs to communicate with each other or for some hierarchy in the order they run . For example 5 EAs running on the same MT4, where in order for each one to run,it has to wait for the previous one to complete its operations.

What I think is to have the EAs create a textfile with a given number, where each of the EAs will be looking for if that file exists in order to begin to operate. If it does exist they will delete it and produce their own.

Can anyone provide a better alternative.

If you want to know what I am trying to achieve more specifically.

I wish to have an EA that automatically changes the chart symbol to the symbol of an active trade, when -that symbol did not have an active trade before.

-there is not an existing chart with that symbol active

I know I can write a function to loop through the active charts and trades and use the ChartSetSymbolPeriod() to change the chart when the above two conditions apply.

My difficulty however lies in the fact that I will apply it to 5 different charts and I want to avoid having all of them change to the same symbol at the same time when the above conditions apply. Hence if they were to executed in order.

Chart 2, will only change if Chart 1 is occupied with active trade. Chart 3 will change only if Chart 1 and Chart 2 are occupied with active trades and so on.

Hence the need for the communications between them or for some hierarchy in their execution.

Thank you


  • Usually people who can’t code don’t receive free help on this forum, though it could happen if you are lucky, be patient.

  • If you show your attempts and describe well your problem, you will most probably receive an answer from the community.

  • If you don’t want to learn to code, nothing bad, you can either look at the Codebase if something free already exists, or in the Market for paid products (sometimes free also).

  • Finally, you also have the option to hire a programmer in the Freelance section

More specifically I would like to bring to attention of all that some people like to ask advice and code, for free on the forum, while they are sellers of signals or products. Of course we can guess it is only for their general culture and never to sell others ideas and code.

Good luck.

Hi pdeeny1z

I appreciate your comment.

What I seek is for personal use.

Rather than to have 20 charts active each on different pair with EAs and use CPU, I thought of having 5, that automatically switch to the symbol of an active trade.

Irrespective of if I am a seller or not I believe I followed the second bullet point , where I have described the problem and provided my suggested solution if somebody had an answer.

I am not seeking for code.

There could be a simple built in function that specifies priority of EAs I am not aware of that does that.

Thank you

ChartID() are created sequentially, with the first chart having the lowest ChartID(). You may store ChartID() in an array and work with it.

The best way to globally look is to utilize the Common directory. Open a file using the FILE_COMMON flag. I would imagine you can set the current symbols in the file and have the program check to see if it is use. Not only will it work among several charts, but also among several metatrader programs including both MQL5 and MQL4

Thank you kaitking.

So your suggestion is by using external files.

Similar to what I proposed.