Loading…

Silent Failure Canary

A trading setup leans on several pieces of plumbing nobody actively watches: the sandbox file system an EA logs or persists state to, an outbound WebRequest a notification or data-fetch integration depends on, and the order-send path itself. All three can fail silently - a full or permission-locked sandbox, a URL that quietly dropped off the terminal's whitelist, a broker-side change that starts rejecting a certain order shape - and the first sign of trouble is often the important EA that actually needed that capability failing at the worst possible moment. This EA is a canary for exactly that. On a configurable interval it writes a small probe file and reads it back to confirm the value round- tripped correctly, and fires a WebRequest at a configured URL, checking both the HTTP status and specifically distinguishing "URL not whitelisted" (error 4060, a configuration problem) from a genuine connection failure, since those need different fixes and conflating them wastes the time spent investigating. The third check - actually sending and immediately closing a real market order to confirm the trade path itself is alive - is the only one that touches money, so it is treated with real caution rather than bundled in by default. It is OFF unless InpEnableDemoOrderTest is explicitly set to true. Even then it will not run unless InpConfirmPhrase is typed exactly as the required confirmation text, and it refuses outright on anything that does not report as a demo account (via ACCOUNT_TRADE_MODE) unless InpAllowOnRealAccount is also explicitly set to true - a second override, deliberately separate from the first two, that should only ever be used in a controlled test on an account whose balance genuinely does not matter. Any failure on any check pops an Alert(), can play a sound, and is always written to the Experts log with a clear pass/fail per check. Notes and limitations - The order round trip, when armed, sends and closes a real market order - it is not a simulation and it does incur spread cost. It exists to confirm the order-send path is alive, not to be run casually or frequently. - ACCOUNT_TRADE_MODE is the only account-type signal this EA checks; a broker that misreports this property would defeat the demo-account refusal. This is a known limitation of the underlying platform API, not something this EA can independently verify. - A WebRequest failure with error 4060 means the URL is not whitelisted in this terminal - it is a configuration gap, not proof of an outage, and is reported as such. - File probe writes and deletes a small file in the sandbox each pass; it does not test disk space exhaustion beyond what a normal small write would reveal. - This EA does not attempt to fix anything it finds broken. It only detects and announces.

Expert advisor · MT4 · v1.0 · Free

About Silent Failure Canary

Silent Failure Canary is an expert advisor (trading robot) for MetaTrader 4. It has 12 settings, such as Check interval min, Test file write and Test web request. MQL source code included.

Files in the download: SilentFailureCanary.ex4, SilentFailureCanary.mq4, SilentFailureCanary.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Check interval min15Minutes between canary passes
Test file writetrueExercise a file write + read-back each pass
Test web requesttrueExercise an outbound WebRequest each pass
Web request urlhttps://www.google.comURL to probe - must be whitelisted in Tools>Options>Expert Advisors
Enable demo order testfalseDANGEROUS - see header. Off by default, on purpose.
Confirm phraseMust exactly equal I UNDERSTAND THIS SENDS A REAL ORDER to arm the order test
Allow on real accountfalseDANGEROUS - overrides the demo-account refusal. Leave false.
Order test lots0.01Lot size for the round-trip test order
Order test magic29801Magic number tagging the round-trip test order
Use alert on failuretruePop an Alert() when any check fails
Use sound on failuretruePlay a sound when any check fails
Failure sound filealert.wavSound file for a failed check

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria