Watch Dog - An EA monitoring script
Info
The Watch Dog - An EA monitoring script is a Script for MetaTrader 4 that 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.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Script works exclusively on MetaTrader 4 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL4/Scripts folder via File ? Open Data Folder in MetaTrader 4.
How to Install and Use Watch Dog - An EA monitoring script
1. Installation: Move your script file into the MQL/Scripts directory and restart the platform.
2. Execution: Drag the script onto a chart; it will perform a one-time action, such as closing all open orders or clearing chart objects.
3. Editing: Use MetaEditor (F4) to modify code, click "Compile," and verify no errors appear in the terminal before running.
4. Removing: Scripts stop automatically, but you can remove them manually by right-clicking the chart and choosing "Remove Script."
Frequently Asked Questions
Q: How are scripts different from EAs? A: Scripts execute a single action and then stop; EAs monitor the market and trade continuously.
Q: Can I assign a hotkey to a script? A: Yes, right-click the script in the Navigator, select "Set Hotkey," and define your preferred keyboard shortcut.
Q: Why did my script stop? A: Scripts are designed to stop immediately after finishing their programmed command; this is normal behavior.
What this tool does
WatchDog is an "Expert Advisor" and "System" monitoring script.
Typical Use Case
This Script excels in automated trading and technical analysis on MetaTrader 4.
Compatible Platform & Setup
This Script works on MetaTrader 4. Place the file in the MQL4/Scripts folder and restart the terminal.
Description & Settings
Related: Market Watch Cleaner - another powerful script for MetaTrader 4 traders.
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.
Also recommended: Market Watch AU T O-CS V - similar script with strong performance on MetaTrader 4.
In order to use this script, you have to:Adjust the BASEDIR value. Set your MetaTrader installation path string BASEDIR = "C:\\Program Files\\MetaTrader4\\";
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.)
Log-Events:
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)
Events:
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.
...also uncomment
Optional:
The Alive-Event calls a php web script every 40 seconds.
To use this event you have to:
Install update.php, check.php and timestamp.txt on a website (with sendmail and php support)
Make timestamp.txt writeable
Enable the Alive-Event. (wdc[WDE_ALIVE][WDC_ENABLED]=1)
You may also like: Attractive Market Watch List for Potential Entries MT4 - excellent alternative for script users on MetaTrader 4.
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.