MonitorEA collects PINGs, sent by other charts, with the purpose of being able to detect that one of these other charts has stopped running (for whatever reason). An EA can stop PINGing if (1) it crashed with a runtime error (eg. zero divide) (2) it is running out or memory (3) it is stuck in an endless loop (4) ... others. Since each chart has only one processing thread, code in the OnTimer() event handler can not run if the thread is stuck in the OnTick() event handler, and vice versa.
It is important to understand that this MonitorEA has a limited use case: It will NOT help you if:
- Empty4 hangs or crashes (eg. as a result of a faulty EA)
- Your computer (or VPS) hangs or crashes
- Your internet is dead
- Your house is burning down
- Your EA has sent a 1000 orders resulting in a margin call ...
How does it work and what does it do?
It is assumed that the EA's to be monitored, are broadcasting a periodic PING message to all the other charts. An example of how this is done can be seen inside the RogueEA.mq4 file (attached), It only requires a few additional lines, particularly:
Code: Select all
#include <Events.mqh>
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer() {
static const string message = StringFormat("%I64d|%s|%s(%d)", ChartID(),WindowExpertName(), _Symbol, _Period);
BroadcastEvent( EVENT_PING, (long)TimeLocal(), 0.0, message );
}Code attached. Have fun.
Update 2016.08.07
There are two small changes to both RogueEA and MonitorEA: RogueEA wasn't sending the full 64-bytes of the long chartID (i.e. the StringFormat was %ld, but should be %I64d). Those 4 early birds should re-download both RogueEA and MonitorEA. It is entirely possible that you would have seen and corrected this already yourself.
