Manually closing deals when running multiple EAs on same account

 

In MT4's ticket-based system, it was fairly easy to manually close one EA's position if I had multiple EA's trading the same pair on the same account. e.g. EA #1 places EURUSD SELL order for 0.1 lots @ 1.30000, EA #2 places EURUSD SELL order for 0.1 lots @ 1.29000 and EA #3 places EURUSD SELL order for 0.1 lots @ 1.28000. If I manually closed EA #2's order, EA #2 would easily see it didn't have an open position any more and the other two EAs would still be happily managing their orders. In MT5, after the three deals are made, there's now one EURUSD position of 0.3 lots shown in the "Trade" tab. Is MT5 strictly a FIFO system where if I manually close 0.1 lots, it automatically closes the 0.1 lots opened by EA #1 and displays a profit in the "History" tab based on EA #1's opening price? Would there be any way for EA #1 to know that it's 0.1 lots were manually closed (other than reading through all the deals of the position and applying FIFO in the code)?

Not knowing for sure if MT5 is a FIFO system, if I wrote a script using EA #2s magic number to close the deal made by EA #2s order, can I get the profit displayed in the "History" tab to co-incide with EA #2's entry price, which also allows EA #2 to see its deal has closed?

It won't make a difference total profit wise when all is said and done and all the deals eventually close, I'm still trying to wrap my head around how manually closing lots placed by one EA in a multiple EA setup effects how each individual EA knows if it has an open deal or not. I've read the article on "Orders, Positions and Deals in MT5" and looked through many of the Order and History functions and can't see how to test for this scenario, especially if MT5 is strictly FIFO in the way it processes partial closing of positions.

Any help would be greatly appreciated.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM - Documentation on MQL5
Reason: