- 
Monitor trades / positions (most dependable) - 
Watch for brand spanking new offers/orders/place modifications utilizing OnTradeTransaction() or by snapshotting PositionsTotal() and PositionGet… properties. 
- 
You possibly can detect: image, quantity, magic quantity, remark, worth, route — then set off your motion. 
- 
Works even when the opposite EA is EX5 as a result of all commerce operations undergo the terminal. 
 
- 
- 
Detect chart objects the EA attracts (arrows, labels) - 
Some EAs draw arrows/textual content once they sign. You possibly can scan chart objects ( ObjectsTotal , ObjectName , ObjectGet ) and react to a brand new object. 
- 
Much less dependable (object naming conventions range). 
 
- 
- 
Learn Terminal International Variables 
- 
Learn recordsdata / shared reminiscence / DLL / home windows messages 
- 
Use iCustom / indicators 
- 
Use commerce/place monitoring. It is easy, dependable and requires no cooperation from the opposite EA. 
- 
If you happen to can not distinguish which EA positioned a commerce, let the person choose a commerce from historical past to “observe”, or auto-detect the primary commerce after attaching your EA and retailer its magic/remark to observe subsequent trades. 
Instance MQL5 EA — listens for different EAs’ commerce exercise and reacts
This EA:
- 
builds a set of at present recognized place tickets on init, 
- 
makes use of OnTradeTransaction() to detect commerce modifications, 
- 
when it sees a new place open or place closed, it calls OnExternalSignalDetected(…) the place you place your customized motion (open hedge, notify, and many others.), 
- 
reveals easy methods to auto-detect the opposite EA’s magic/remark or let person specify it. 
Paste the code into MetaEditor as a brand new EA and compile.
#property copyright "Instance" #property model "1.00" #property strict enter lengthy FollowMagic = -1; enter string FollowComment = ""; enter bool AutoDetect = true; ulong knownTickets[]; void AddKnownTicket(ulong ticket) { for(int i=0;i<ArraySize(knownTickets);i++) if(knownTickets[i]==ticket) return; ArrayResize(knownTickets, ArraySize(knownTickets)+1); knownTickets[ArraySize(knownTickets)-1] = ticket; } void RemoveKnownTicket(ulong ticket) { int idx=-1; for(int i=0;i<ArraySize(knownTickets);i++) if(knownTickets[i]==ticket) { idx=i; break; } if(idx==-1) return; for(int j=idx;j<ArraySize(knownTickets)-1;j++) knownTickets[j]=knownTickets[j+1]; ArrayResize(knownTickets, ArraySize(knownTickets)-1); } bool IsKnownTicket(ulong ticket) { for(int i=0;i<ArraySize(knownTickets);i++) if(knownTickets[i]==ticket) return true; return false; } int OnInit() { ArrayResize(knownTickets,0); int whole = PositionsTotal(); for(int i=0;iif(PositionSelectByIndex(i)) { ulong ticket = (ulong)PositionGetInteger(POSITION_TICKET); AddKnownTicket(ticket); } } Print("FollowExternalTrades initialized. Recognized positions: ", ArraySize(knownTickets)); return(INIT_SUCCEEDED); } void OnDeinit(const int cause) { } void OnTradeTransaction(const MqlTradeTransaction &trans, const MqlTradeRequest &request, const MqlTradeResult &outcome) { DetectPositionChanges(); } void DetectPositionChanges() { ulong currentTickets[]; ArrayResize(currentTickets, 0); int whole = PositionsTotal(); for(int i=0;i if(PositionSelectByIndex(i)) { ulong ticket = (ulong)PositionGetInteger(POSITION_TICKET); ArrayResize(currentTickets, ArraySize(currentTickets)+1); currentTickets[ArraySize(currentTickets)-1] = ticket; } } for(int i=0;i<ArraySize(currentTickets);i++) { ulong t = currentTickets[i]; if(!IsKnownTicket(t)) { if(PositionSelectByTicket(t)) { lengthy magic = (lengthy)PositionGetInteger(POSITION_MAGIC); string remark = PositionGetString(POSITION_COMMENT); string sym = PositionGetString(POSITION_SYMBOL); double vol = PositionGetDouble(POSITION_VOLUME); int ptype = (int)PositionGetInteger(POSITION_TYPE); datetime time = (datetime)PositionGetInteger(POSITION_TIME); bool match = true; if(FollowMagic>=0 && magic!=FollowMagic) match = false; if(StringLen(FollowComment)>0 && remark!=FollowComment) match = false; if(AutoDetect && FollowMagic==-1 && match) { FollowMagic = magic; PrintFormat("Auto-detected FollowMagic = %d (remark="%s")", FollowMagic, remark); } if((FollowMagic==-1 || magic==FollowMagic) && (StringLen(FollowComment)==0 || remark==FollowComment)) TIME_SECONDS)); OnExternalSignalDetected(true, t, sym, ptype, vol, magic, remark, time); AddKnownTicket(t); } } } int knownCount = ArraySize(knownTickets); for(int i=knownCount-1;i>=0;i--) { ulong t = knownTickets[i]; bool stillExists = false; for(int j=0;j<ArraySize(currentTickets);j++) if(currentTickets[j]==t) { stillExists=true; break; } if(!stillExists) { PrintFormat("Detected CLOSED place ticket=%I64u", t); OnExternalSignalDetected(false, t, "", -1, 0.0, 0, "", 0); RemoveKnownTicket(t); } } } void OnExternalSignalDetected(bool is_open, ulong ticket, string image, int pos_type, double quantity, lengthy magic, string remark, datetime open_time) { if(is_open) { PrintFormat("*** ACTION: exterior OPEN detected. Ticket=%I64u image=%s sort=%d vol=%.2f magic=%d remark=%s", ticket, image, pos_type, quantity, magic, remark); } else { PrintFormat("*** ACTION: exterior CLOSE detected. Ticket=%I64u", ticket); } } bool PositionSelectByTicket(ulong ticket) { for(int i=0;i<PositionsTotal();i++) { if(PositionSelectByIndex(i)) { if((ulong)PositionGetInteger(POSITION_TICKET) == ticket) return true; } } return false; } void OnTick() { } 
