how is multiple EA trigger order handled?

 

Setup: Have multiple instances of the same EA applied to different windows each containing a different currency symbol. Each instance has its own unique magic number.

Question: In what order do the EAs trigger? Is there any way to control this? For example, does the window where the first EA was applied get triggered before the second window and so on?

Having said control is needed for instances where multiple different currencies might trigger at the same time and there may be a preference for one over the other to be acted upon before margin is exceeded.

Just wondering if there's a way to control trigger order short of rolling all separate instances into a single EA (which would be a bit of work).

 

You could use a global bool variable that you switch on and off whenever an EA is trying to make it's trade. Then the order of trades is simply the order of EAs coming to the trading logic. Set a loop that's checking that variable and make the EA wait(Sleep) for it's turn.

Another way (although WHRoeder somewhere said that it's not as recommended, would be best if he explained it) is to use IsTradeAllowed() that checks whether the trading thread is free.

If you're saying that all your EAs are completely the same and should use exactly the same amount of time to get to the point of trading, then you'll have to accept that EAs need to wait for their (random) turns. If you need this to be controlled, I suggest you create your own controllor logic for it.

o/

 
billworld:

Setup: Have multiple instances of the same EA applied to different windows each containing a different currency symbol.

Question: In what order do the EAs trigger?

When a new tick for a currency comes in, indicators are updated on all charts with that symbol, then all EAs not running are called for that symbol.

The other EA is on another pair, it will not be triggered, until that pair has a new tick.

Reason: