program execution

 
If i have an EA monitoring my account and able to close all my positions like:
OnTimer()  //a 1 second timer
{
If(AccountEquity()>target){
 Close all positions with certain MagicNumber}}

And at the same time have many EAs on as many Instruments, that Open positions at the same time like:

OnTick()
{
If(No_open_positions){
 If(Some_Indicator>certain_value){
  Open_a_Position with certain MagicNumber}}}

Then can someone explain to my how the second EA is opening positions while the first EA is in the process of closing?  

I thought that when one EA is executing, other EAs have to wait before it is finished. 

Does the OnTick() vs OnTimer() have something to do with it?

 
Route206: If i have an EA monitoring my account and able to close all my positions like: And at the same time have many EAs on as many Instruments, that Open positions at the same time like: Then can someone explain to my how the second EA is opening positions while the first EA is in the process of closing?  I thought that when one EA is executing, other EAs have to wait before it is finished. Does the OnTick() vs OnTimer() have something to do with it?

EAs are run independently of each other. If you don't want them to collide, then you can make use of a "magic number" on orders so that they only carry out trade operations on their own set.

If your Closing EA is ignoring magic numbers and simply closing all positions irrespectively, then it will collide with other EAs that are monitoring their own trades and try to restabilise them if they are programmed to do so. Those other EAs will also not know if you want to stop trading after all positions are closed and will just continue to work as usual.

 

Also, each EA is run on a different chart (even if it is on the same symbol) and will have their own independent OnTick() and OnTimer() handlers. Those handlers are not shared among the EAs. Each EA has its own event handler.

 

Aah.. OK thanks  -  i confused 'dropped ticks when an EA has not finished with its OnTick() program execution', with 'only 1 EA running at any one time'. The latter is not true and they are clearly two different things. I guess i need to set a GlobalVariable preventing any EA to open any positions when the 'closing program' is executing. 

thanks again!