Version Update Checker
Most home-grown "check for update" code either assumes WebRequest will always succeed (and then breaks the moment a user has not whitelisted the URL, or is offline, or the host is down) or hardcodes a version string comparison so naive it gets multi-digit fields wrong - treating "1.9.9" as newer than "1.10.0" because "9" sorts after "1" as text. This library fixes both problems. The comparison core parses a plain "MAJOR.MINOR.PATCH" string into three integers and compares them numerically field by field, so "1.10.0" is correctly newer than "1.9.9". Two independent check modes share that core: VucCheckLocal() compares two version strings the caller already has, with no network involved at all - this is what keeps the demo compiling and running clean with no live connection. VucFetchLatestVersionFromUrl() and the combined VucCheckForUpdate() add an optional online check via WebRequest, and treat every failure mode (URL not in the terminal's whitelist, WebRequest disabled entirely, no connection, timeout, a non-200 HTTP status, an empty response body) as a graceful fallback to a caller-supplied figure rather than a fatal error - GetLastError() is read and folded into a human-readable message either way, so the Experts log always says exactly why the online check did or did not happen. Note this library's version parser is intentionally simpler than full SemVer 2.0.0 (no pre-release/build tags, no leading-zero rejection) - it exists to answer "is a newer three-field version published", not to sort a changelog. Full SemVer precedence, if a project genuinely needs it, is a separate concern; this file reimplements only the plain three-field comparison it needs internally rather than depending on any other catalogue submission (per house style, a Library never includes another project's file). Notes and limitations - The parser accepts only exactly three dot-separated non-negative integer fields ("2.3.1"). No "v" prefix, no two-field short form, no pre-release/build tags - pass a plain three-field string. - WebRequest cannot be exercised in an unattended compile check or a fresh terminal install (the URL is never whitelisted by default), which is exactly why the local mode exists standalone and the URL mode is designed to degrade rather than fail outright. - VucFetchLatestVersionFromUrl() expects the response body to contain nothing but the version string itself (whitespace/newlines are trimmed). A real API returning JSON or HTML needs its own parsing before calling VucCheckLocal() with the extracted value. - The registry/report has no persistence and no automatic scheduling - callers decide when to check (e.g. once in OnInit(), or on a timer) and how to store the last-known "latest" figure between runs if they want to avoid a fresh network call every tick.
Script · MT4 · v1.0 · Free
About Version Update Checker
Version Update Checker is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 5 settings, such as Program name, Current version and Version url. MQL source code included.
Files in the download: VersionUpdateChecker.mqh, VersionUpdateChecker.txt, VersionUpdateCheckerDemo.mq4.
Settings
| Setting | Default | What it does |
|---|---|---|
| Program name | VersionUpdateCheckerDemo | Name shown in notifications |
| Current version | 2.3.1 | Version this "program" claims to be running |
| Version url | https://example.com/latest_version.txt | Optional: URL publishing the latest version as plain text |
| Fallback latest version | 2.4.0 | Used when the URL check is unavailable |
| Show alert popup | false | Show a blocking Alert() popup if an update is found |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Script · MQL4 Source Code