Home / Blog / Add License Verification to Your EA in 10 Minutes | MQL4/MQL5 Tutorial

Add License Verification to Your EA in 10 Minutes | MQL4/MQL5 Tutorial

License verification system for an MT4 and MT5 Expert Advisor using security checks

Want to protect your Expert Advisor from unauthorized use? This tutorial shows you exactly how to add license verification to your MT4 or MT5 EA —in under 10 minutes. No servers. No databases. No backend experience required.

What You’ll Build

By the end of this tutorial, your EA will:

  1. Check license status on every startup, and again every hour while it runs
  2. Auto-register new users as trial accounts
  3. Display trial days remaining to prospects
  4. Block execution when license is invalid or expired

You’ll manage everything from a web dashboard —no recompiling needed.

Prerequisites

Step 1: Create Your LicenseShield Account

  1. Go to licenses.barmenteros.com/register
  2. Enter your email and create a password
  3. Verify your email (check spam folder if needed)
  4. Log in to your dashboard

On the dashboard, click Generate API Key and copy the key. Keep this tab open —you’ll need it in Step 3.

Step 2: Download the MQL Library

The integration kit is three files. On the dashboard, the Quick Start Guide has a download button for each one, under a MetaTrader 4 and a MetaTrader 5 tab:

  1. Pick your platform’s tab and download LicenseShield.mqh, LicenseShieldGuardCore.mqh and LicenseShieldEA.ex4 (MT4) or LicenseShieldEA.ex5 (MT5)
  2. In MetaEditor, choose File → Open Data Folder and open the MQL4 folder (MT5: MQL5)
  3. Copy each file into its folder:
    • LicenseShield.mqh and LicenseShieldGuardCore.mqh → Include\
    • LicenseShieldEA.ex4 or LicenseShieldEA.ex5 → Libraries\

An EA needs no DLL: the kit verifies over MetaTrader’s WebRequest. Protecting an indicator instead? It uses LicenseShieldInd.mqh and does need “Allow DLL imports”; the Docs page in your dashboard covers it.

Step 3: Add Verification to Your EA

Press F4 in MetaTrader to open MetaEditor and open your EA’s source file. Add the #include and #define lines near the top, then call the two guard functions from OnInit() and OnTick(), as below. The code is the same on both platforms; only the file names in the comments differ.

MQL4 Version

//+------------------------------------------------------------------+
//| LicenseShield Integration (MT4) - one include + two calls        |
//+------------------------------------------------------------------+
// FILES (from the Download buttons above):
//   LicenseShield.mqh          -> MQL4\Include\
//   LicenseShieldGuardCore.mqh -> MQL4\Include\
//   LicenseShieldEA.ex4        -> MQL4\Libraries\
// SETUP: In MetaTrader (Tools > Options > Expert Advisors):
//   "Allow WebRequest for listed URL" - add: https://api-licenses.barmenteros.com
//   No "Allow DLL imports" needed - EAs verify over WebRequest only.
#include <LicenseShield.mqh>
// Your API Key (keep this secret - do not expose as an input!)
#define API_KEY "YOUR_API_KEY"
int OnInit()
{
   // Verifies on startup; a new account gets a free trial automatically.
   // Retries brief connection problems; fails only on a genuine rejection.
   if(LicenseShield_Guard_OnInit(API_KEY) == INIT_FAILED)
   {
      return INIT_FAILED;
   }
   // ... your existing initialization code here ...
   return INIT_SUCCEEDED;
}
void OnTick()
{
   // Re-verifies every 60 minutes. On a connection drop it keeps the last
   // good result; it stops the EA only if the server rejects the license.
   if(!LicenseShield_Guard_Tick())
   {
      return;
   }
   // Your trading logic here
}

MQL5 Version

//+------------------------------------------------------------------+
//| LicenseShield Integration (MT5) - one include + two calls        |
//+------------------------------------------------------------------+
// FILES (from the Download buttons above):
//   LicenseShield.mqh          -> MQL5\Include\
//   LicenseShieldGuardCore.mqh -> MQL5\Include\
//   LicenseShieldEA.ex5        -> MQL5\Libraries\
// SETUP: In MetaTrader (Tools > Options > Expert Advisors):
//   "Allow WebRequest for listed URL" - add: https://api-licenses.barmenteros.com
//   No "Allow DLL imports" needed - EAs verify over WebRequest only.
#include <LicenseShield.mqh>
// Your API Key (keep this secret - do not expose as an input!)
#define API_KEY "YOUR_API_KEY"
int OnInit()
{
   // Verifies on startup; a new account gets a free trial automatically.
   // Retries brief connection problems; fails only on a genuine rejection.
   if(LicenseShield_Guard_OnInit(API_KEY) == INIT_FAILED)
   {
      return INIT_FAILED;
   }
   // ... your existing initialization code here ...
   return INIT_SUCCEEDED;
}
void OnTick()
{
   // Re-verifies every 60 minutes. On a connection drop it keeps the last
   // good result; it stops the EA only if the server rejects the license.
   if(!LicenseShield_Guard_Tick())
   {
      return;
   }
   // Your trading logic here
}

Replace YOUR_API_KEY with the API key from your dashboard, and keep it in the #define: an input would show it to anyone who runs the EA.

Step 4: Enable WebRequest

Before testing, you need to allow your EA to make web requests:

  1. In MetaTrader, go to Tools → Options → Expert Advisors
  2. Check “Allow WebRequest for listed URL“
  3. Add: https://api-licenses.barmenteros.com (the API address, not the dashboard)
  4. Click OK

“Allow DLL imports” is not needed: the EA kit verifies over WebRequest only.

Step 5: Compile and Test

  1. Compile your EA in MetaEditor (F7)
  2. Attach to any chart in your demo terminal
  3. Check the Experts tab for the verification result

You should see something like:

LicenseShield: guard v1.1.0 starting (re-verify every 60 min)
LicenseShield_Verify: License verified - TRIAL (7 days remaining)
LicenseShield: license verified

The exact status and day count depend on the license.

Step 6: Check Your Dashboard

Go back to your LicenseShield dashboard and scroll to Program Users (Licenses).

You’ll see a new entry:

AccountBrokerStatusLast Seen
12345678Name-Demo01Trial (7 days)Just now

This account was auto-registered as a trial. No manual setup needed!

Managing Licenses

Approving a Paid Customer

When a customer pays (or you want to extend a trial):

  1. Find their account in your license list
  2. Look for the Actions column on the right
  3. Click the Reactivate or Enable button
  4. Done —the Status updates to “Active” immediately

Revoking Access

If a customer requests a refund or their subscription expires:

  1. Find their account
  2. Click the Disable button in the Actions column
  3. The Status changes to “Disabled“
  4. A running EA stops at its next check (every 60 minutes by default), and it will not start again

Viewing Activity

The Last Seen column shows when each license was last verified. Use this to:

  • Identify active vs. inactive customers
  • Track trial users who might convert
  • See which accounts are actually using the EA

Handling Edge Cases

What if the user has no internet?

At start-up the EA must reach our server. It tries three times, then returns INIT_FAILED and shows an alert that names the internet connection and the WebRequest setting. This is by design: an EA that could start offline could skip its license check. If the connection drops while the EA is already running, it keeps working (see below).

What about Strategy Tester?

The library detects the Strategy Tester and skips the license check there, so your EA works in backtests without license issues. Live and demo charts always verify.

What if LicenseShield is down?

LicenseShield runs serverless on a cloud server infrastructure (99.9%+ uptime). If a running EA briefly can’t reach our servers, it keeps its last verified license state and retries at the next interval — it only stops on an actual license rejection, and it never fabricates a valid license. A fresh chart attach does require a successful verification.

Upgrading Beyond Free Tier

The Free tier includes:

  • 10 verifications/day
  • 1 license
  • 7-day fixed trial period

If you’re selling more EAs or need higher limits, view pricing →

Summary

You’ve just added professional license verification to your EA:

  1. Created a LicenseShield account
  2. Downloaded the three kit files
  3. Added one include and two guard calls
  4. Enabled WebRequest
  5. Tested the integration

Total time: About 10 minutes.

Now you can focus on building great trading software —LicenseShield handles the licensing.

Questions? Reply to any LicenseShield email or contact [email protected].

Ready to protect your EA?

Leave a Reply

Your email address will not be published. Required fields are marked *

Get a free quote

Fixed price within 24–48 hours. No subscriptions, no demos.