How Grit Markets license validation works (with MQL5 reference)
Grit Markets activates by calling the licence endpoint at https://gritmarkets.com/api/license/validate over HTTPS from inside MetaTrader 5. This page documents exactly what the EA sends, what comes back and how the EA behaves in each case, so you know precisely what the software does on your machine. The reference MQL5 implementation below is the same pattern compiled into the EA; it is published for transparency and for anyone auditing the product before subscribing.
The EA sends a validation request on startup
When Grit Markets initialises on a chart, it sends a single HTTPS POST to https://gritmarkets.com/api/license/validate containing three values: your licence key, the MT5 account number the terminal is logged into, and the EA version. Nothing else is transmitted — no trade history, no balance, no personal data beyond the account number the licence binds to.
MT5 must allow the WebRequest URL
MetaTrader 5 blocks all outbound web requests unless the destination is whitelisted. Add https://gritmarkets.com under Tools, Options, Expert Advisors, Allow WebRequest for listed URL. If the URL is missing, WebRequest returns error 4014 and the EA shuts down gracefully without trading.
The server answers in under a second
The endpoint returns a small JSON document: valid (true or false), reason (a short machine-readable code such as ok, bound, license_suspended or subscription_canceled) and expires (the end of the current billing period). The EA parses this and either arms itself or reports the reason in the Experts log and removes itself from the chart.
First use binds your account automatically
The first time a licence validates from a new MT5 account, the account number binds to the licence automatically, up to your tier's account limit. After that, validation from a bound account returns valid immediately. To move the EA to a different account, unbind the old account from your dashboard — self-service rebinds are limited to two per rolling thirty days.
Revalidation is periodic, not per-trade
The EA revalidates on a timer measured in hours, never inside trading logic, so a temporary network problem cannot interfere with an open recovery sequence. If validation fails persistently, the EA stops opening new sequences but manages any open positions to their configured close.
// Grit Markets — licence validation reference (MQL5)
// The endpoint below is fixed for the lifetime of the product and must be
// whitelisted in MT5: Tools > Options > Expert Advisors > Allow WebRequest.
#define GM_LICENSE_ENDPOINT "https://gritmarkets.com/api/license/validate"
input string InpLicenseKey = ""; // Your GM-XXXXX-XXXXX-XXXXX-XXXXX key
bool GM_ValidateLicense(const string ea_version)
{
string account = IntegerToString(AccountInfoInteger(ACCOUNT_LOGIN));
string body = StringFormat(
"{\"license_key\":\"%s\",\"mt5_account\":\"%s\",\"ea_version\":\"%s\"}",
InpLicenseKey, account, ea_version);
char request[];
StringToCharArray(body, request, 0, StringLen(body), CP_UTF8);
char response[];
string response_headers;
ResetLastError();
int status = WebRequest("POST", GM_LICENSE_ENDPOINT,
"Content-Type: application/json\r\n",
5000, request, response, response_headers);
if(status == -1)
{
// 4014 => URL not whitelisted in Tools > Options > Expert Advisors
PrintFormat("Grit Markets: WebRequest failed, error %d. "
"Whitelist %s in MT5 options.",
GetLastError(), GM_LICENSE_ENDPOINT);
return(false);
}
string json = CharArrayToString(response, 0, WHOLE_ARRAY, CP_UTF8);
bool valid = (StringFind(json, "\"valid\":true") >= 0);
if(!valid)
PrintFormat("Grit Markets: licence rejected — %s", json);
return(valid);
}
int OnInit()
{
if(!GM_ValidateLicense("1.0.0"))
{
// graceful shutdown: no trading without a valid licence
ExpertRemove();
return(INIT_FAILED);
}
return(INIT_SUCCEEDED);
}Notes
- The endpoint URL never changes. If a future EA version ever asked you to whitelist a different domain, treat it as suspect and contact support.
- Validation telemetry (licence key, MT5 account number, IP address) is logged for licence enforcement, as described in the Privacy Policy.