Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2012.02.21 07:07

WatchDog - An EA monitoring script. - script for MetaTrader 4

| English Español Português 日本語 Deutsch

votes: 9

WatchDog is an "Expert Advisor" and "System" monitoring script.

WatchDog sends an e-mail when things go wrong, an order has opened or closed, on requotes, on log errors, on server shut down ... Just drag the script in a chart window.

In order to use this script, you have to:

  1. Adjust the BASEDIR value. Set your MetaTrader installation path string BASEDIR = "C:\\Program Files\\MetaTrader4\\";
  2. Setup MetaTrader for Email notification. (Tools -> Options -> Email)
  3. Optional: A Webspace with PHP support. Only necessary if you want to use the server alive-event. (This event is disabled by default)

The script is based on events; each event defines a monitoring task. WatchDog comes with a lot of pre-defined events. But it's also possible to add custom events. Later on I'll explain how to do this. Basically there are two types of events, events and log-events. A log-event searches the given log file for a string. The different between events and log-events is just the parameter count. Log-events always expect a log file name and a search pattern.

Here comes a short description of all events. (Each event has its own event-id which is defined in the source.)


  • WDE_JL_DELETED: Searches the journal-log (every minute) for "order deleted" and mails any corresponding line.
  • WDE_JL_REQUOTE: Searches the journal-log (every minute) for "requote" and mails any corresponding line.
  • WDE_JL_FAILED: Searches the journal-log (every minute) for "failed" and mails any corresponding line.
  • WDE_JL_EALOADED: Helper event
  • WDE_JL_EAREMOVED: Sends a mail when an EA script was removed or loaded. (1 min. check interval)


  • WDE_ALIVE: A helper event that invokes an URL (every 40 seconds)
  • WDE_CONNECTIVITY: Sends a mail when MetaTrader has lost the connection.
  • WDE_OPENCLOSE: Invokes a WDE_STATEMEN-event when an order has opened or closed.
  • WDE_STATEMENT: Sends (every hour) information about active trades, closed trades and account values.
  • WDE_ERROR: Sends information about errors.

To change or add an event, go to the init() function. Below the "Event configuration" comment-line, you can add or update event parameters.
Furthermore, if you add an event, you have to uncomment or add the corresponding line within the switch statement. Search the script for "custom1" to see what I mean.

For example to add a log-event (WDE_JL_custom1) that searches the journal log for "error", just uncomment and update these lines.

//   wd_eventTitle[WDE_JL_custom1]         = "Custom1";           // email subject
//   wdc[WDE_JL_custom1][WDC_ENABLED]      = 1;                   // event 0=disabled / 1=enabled
//   wdc[WDE_JL_custom1][WDC_INTERVAL]     = 60;                  // check-interval in seconds
//   wdc[WDE_JL_custom1][WDC_NORMALLEVEL]  = 1;                   // perform a normal-action if level-counter is >= 1
//   wdc[WDE_JL_custom1][WDC_NORMALACTION] = WDA_MAIL|WDA_RESET;  // normal-action: send mail and clear level-counter
//   wd_logPath[WDE_JL_custom1]            = BASEDIR+"logs\\";    // journal log path
//   wd_match1[WDE_JL_custom1]             = "error";             // first pattern

...also uncomment

            switch(event) {
//             case WDE_JL_custom1:


The Alive-Event calls a php web script every 40 seconds.

To use this event you have to:

  1. Install update.php, check.php and timestamp.txt on a website (with sendmail and php support)
  2. Make timestamp.txt writeable
  3. Set the WD_URL ( #define WD_URL "" )
  4. Modify update.php, check.php (adjust IP and Email addresses)
  5. Use a free cronjob service to call "" every 2 minutes. (If the update.php script fails, check.php sends an alert mail)
  6. Enable the Alive-Event. (wdc[WDE_ALIVE][WDC_ENABLED]=1)


It is a Malty order Placer(4 LIMIT and 1 INSTANT). and good performed EA. It Works With THE Co-ordination of Different Moving Averages.

Time trader v1.1 Time trader v1.1

Opens specified orders at a specified time

Clear Method Clear Method

This indicator is based on the article: Getting Clear With Short-Term Swings by Ron Black

Bill Williams ATZ indicator Bill Williams ATZ indicator

This indicator throws visual and verbose buy/sell signals according to Bill Williams Trading in the Zone methodology and Alligator.