Is the task solvable in principle in MQL4 ?

 

The task is: In one terminal, there are 9 different pairs, and 8 EAs working on each of them, and each is allowed to trade on the 9th pair, my 'managing' EA, which monitors how many pairs and respectively copies of trading EAs may open orders at the same time. All Expert Advisors obey one GLOBAL variable. I have written a simple loop which reads "magic numbers" of already opened orders and does not allow opening new orders of other EAs setting the value of the controlling global variable which forbids trading.

This is how it should be "under the scenario". That's not how it really works. The problem is that until my 'managing' EA has time to set the value of the global variable prohibiting trading, the working EAs have time to open orders on 6 pairs instead of the allowed 2. The algorithm works correctly, if I first start the EA manager and then let trading EAs trade, then more than 2 EAs (2 pairs) will not open (forbidden by the global variable set by the EA manager).

Is it possible to set in MQL4 a system of priorities, so that first the EA's code is executed, and then all other EAs ?

I tried to loop start(), maybe I did something wrong but the terminal hangs up.

Help for a novice pro.

 
Zakyza:

Is it possible to set a system of priorities in MQL4, so the EA code is executed first, and then all other EAs?

I tried to loop start(), maybe I did something wrong, but I got nothing but suspension of the terminal.

For a beginner pro, I need some help.

It's possible. For example, by adding one more variable for terminal, which only he can manage, and for others it will become a permission to work.

I understand that I suggested what you have already implemented. Apparently, it is done incorrectly.

If the managing advisor has not had time to change the terminal variable, the slaves should not be allowed to trade.

 
Look at this function. This is the only function in MQL4 that handles kernel level (provides atomic access). It should help.
 
tara:
Possible. For example, by adding another terminal variable which only he can control, and for others it will become permission to work.


No time for the EA manager to set the desired value of the global variable
 
Zakyza:

The EA manager does not have time to set the right value of the global variable

Well, you don't have to give the slave the right to breathe until he wakes up.
 
Zhunko:
Look at this function. This is the only function in MQL4 that handles kernel level (provides atomic access). It should help.

Thank you, I hope it helps, I have missed it somehow. "can be used for semaphore organization when several simultaneously working Expert Advisors interact within a single client terminal" - it gives hope. Although, if GlobalVariableSetOnCondition is called from start() of my EA in the last turn, after EAs have already entered deals, I don't know what difference it will make .
 
tara:

Well, you don't have to give the slave the right to breathe until he wakes up.

How do you organise this? Allowing the slaves to trade manually is not an option.
 
If the slave advisers are stolen advisers, you've gone to the wrong address.
 
Why stolen? The author of the EA himself put it out there for free, I just run a few copies and want to organise them through global variables. Why do you say that ?
 
I said: if.
 
tara:
I said: if.

Okay. No, not stolen.
Reason: