Endpoint Health Prober
Any tool that depends on something outside the terminal - a licence check, a sentiment or news feed, a heartbeat URL for a VPS watchdog - eventually needs to answer two boring but important questions: is it reachable right now, and has it been reliable lately. A single WebRequest call answers the first question for one moment in time; it says nothing about whether an endpoint has been flaky over the last hour. This header wraps WebRequest with timing (GetTickCount before and after the call) and classifies the outcome as up or down from the HTTP status code, then records that outcome into a small ring buffer kept per endpoint. The ring buffer is a fixed-size struct member, not a dynamic array, so the history struct itself can be assigned and passed around as an ordinary value with no manual deep-copy step - MQL4 gives no safe default copy once a struct holds a dynamic array, so a fixed cap (EHP_HISTORY_SIZE, 20 by default) was chosen deliberately over an unbounded log. The specific trap this header names explicitly rather than reporting as a bare error code: WebRequest returns -1 with GetLastError() 4014 the moment a domain is not on the terminal's WebRequest allow-list (Tools > Options > Expert Advisors), which is a manual, per-terminal setting no script can set on its own behalf. EhpProbeOne recognises that specific code and returns a message telling the caller exactly what to do, instead of a number that looks like a generic network failure. Notes and limitations WebRequest is a synchronous, blocking call - probing from inside OnTick on every tick will stall the whole EA for up to InpTimeoutMs on a slow or dead endpoint. Probe on a timer (EventSetTimer) or throttle by GetTickCount interval instead. HTTP status codes 200-399 are treated as "up"; a server that returns a 4xx/5xx page but still technically answers is correctly reported as down, which is the intended behaviour for a health check. This header measures reachability and latency only - it does not validate response body content; layer that check on top of the returned response array in EhpProbeOne if the endpoint's payload itself needs verifying. The rolling history has no timestamps, only the most recent EHP_HISTORY_SIZE outcomes - it answers "how has it been lately", not "when exactly did it go down".
Script · MT5 · v1.0 · Free
About Endpoint Health Prober
Endpoint Health Prober is a script for MetaTrader 5. It has 3 settings, such as Endpoint one url, Endpoint two url and Timeout ms. MQL source code included.
Files in the download: EndpointHealthProber.mq5.mqh, EndpointHealthProber.txt, EndpointHealthProberDemo.ex5, EndpointHealthProberDemo.mq5.
Settings
| Setting | Default | What it does |
|---|---|---|
| Endpoint one url | https://www.google.com/ | first endpoint to probe |
| Endpoint two url | https://www.example.com/ | second endpoint to probe |
| Timeout ms | 5000 | WebRequest timeout, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: News Trading · Arbitrage · MT5 Script · MQL5 Source Code