Terminal Watchdog
- Utilities
-
Ganzorig Munkhbayar
Test - Version: 1.0
- Activations: 5
A utility for anyone who leaves MetaTrader 5 running on a VPS or a home computer. Attach it to one chart: every few seconds it checks the things that silently stop Expert Advisors from working, and tells you when a problem starts and when it recovers - with the terminal's alert window, a push notification to the MetaTrader app on your phone, and a line in the Journal. It never opens, modifies or closes a trade on a live account.
What it watches
- Connection to the trade server, and a ping above your limit.
- Algo Trading switched off in the terminal; trading not allowed on the account (e.g. an investor password), or Expert Advisors not allowed by the broker.
- Frozen price feed on the symbols you choose: no new tick for N minutes while the symbol's quote session is open. Weekends, daily breaks and the last 5 minutes before a session closes are not judged, and the grace restarts when a session opens or the connection returns - so it does not cry wolf every night.
- Expert Advisors on every chart of the terminal: it remembers which EA is on which chart and reports one that disappears (chart closed, EA removed, or stopped by an error) and, if you like, one that is added. It also remembers the list across a restart and reports an EA that did not come back.
- Margin level below your limit while positions are open.
- Clock drift: this computer's clock (as the terminal converts it to server time) against the time stamps of incoming ticks.
- Optional status line every N minutes (Journal, and push if you want a "still alive" message on your phone).
How messages are limited
- A problem must last Confirm_Seconds (a disconnection Disconnect_Seconds) before the first alarm; while it lasts you get a reminder every Repeat_Minutes; when it is gone, one "recovered" message with its duration.
- A disconnection while every watched market is closed (weekend, daily break) is held and alarmed only if it lasts into open market hours (Quiet_When_Closed).
- Push notifications are queued so the terminal's own limit (about 10 a minute) is never exceeded; several messages share one push when needed. At most 6 alert windows a minute.
What it cannot do - please read
- If the computer itself loses the internet, is switched off or the terminal closes, no push can arrive - a push leaves through the same connection that failed. The watchdog tries to send a "stopped" message when it is removed or the terminal closes, but after a crash or a power cut there is only silence. If you need to know about that case, switch on the status line push (Heartbeat_Push) and treat a missing status message as an alarm.
- Push notifications need your MetaQuotes ID in Tools - Options - Notifications; the watchdog warns at start if they are off.
- It cannot see whether a single EA's own "Allow Algo Trading" box is ticked, nor whether an EA is working correctly - only whether it is on its chart.
- A symbol that publishes no quote-session table cannot be judged for a frozen feed; the watchdog says so at start.
- The clock check only sees a difference the terminal itself does not correct; it needs ticks on the chart's symbol.
- One watchdog per terminal; a second chart with it waits and takes over if the first is closed.
- Strategy Tester: there is no terminal to watch in the tester, so there (and only there) it opens one minimum-volume position a day with a stop loss and closes it after 6 hours (Tester_Demo); the margin level check and the status line run on the tester account. Tester_Self_Test simulates each alarm once a tester day to show the messages.
Inputs (0 = off for every threshold)
- Check_Seconds (5), Confirm_Seconds (20), Repeat_Minutes (30), Quiet_When_Closed (true).
- Watch_Connection (true), Disconnect_Seconds (90), Max_Ping_Ms (1000).
- Watch_AutoTrading (true), Watch_Account_Trading (true).
- Watch_Symbols (empty = this chart's symbol; e.g. EURUSD;XAUUSD ), Feed_Frozen_Minutes (5).
- Watch_EAs (true), Report_Added_EAs (true), Remember_EAs (true).
- Min_Margin_Level_Pct (200), Max_Clock_Drift_Sec (60).
- Alert_Popup (true), Push_Notify (true), Message_Tag (empty = the account number; e.g. VPS-1 ), Start_Message (true), Heartbeat_Minutes (60), Heartbeat_Push (false), Show_Panel (true).
- Tester_Demo (true), Tester_Self_Test (false) - Strategy Tester only.
Files: it writes only MQL5\Files\TerminalWatchdog\experts.txt (the remembered EA list). No DLL, no web requests. All texts are in English.
