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:
- Check license status on every startup
- Auto-register new users as trial accounts
- Display trial days remaining to prospects
- Block execution when license is invalid or expired
You’ll manage everything from a web dashboard —no recompiling needed.
Prerequisites
- An MQL4 or MQL5 Expert Advisor (any working EA)
- A free LicenseShield account at licenses.barmenteros.com
- 10 minutes
Step 1: Create Your LicenseShield Account
- Go to licenses.barmenteros.com/register
- Enter your email and create a password
- Verify your email (check spam folder if needed)
- Log in to your dashboard
You’ll see your API Key on the dashboard. Keep this tab open —you’ll need it in Step 3.
Step 2: Download the MQL Library
From your dashboard:
- Click Quick Start in the sidebar
- Download `LicenseShield.ex4` (for MT4) or `LicenseShield.ex5` (for MT5)
- Save it to your MetaTrader `Libraries` folder:
- MT4: `C:\Users\[You]\AppData\Roaming\MetaQuotes\Terminal\[ID]\MQL4\Libraries\`
- MT5: `C:\Users\[You]\AppData\Roaming\MetaQuotes\Terminal\[ID]\MQL5\Libraries\`
Step 3: Add Verification to Your EA
Open your EA’s source file and add these lines:
MQL4 Version
#import "LicenseShield.ex4"
bool VerifyLicense(string vendorId, string apiKey);
#import
// Add this at the top of OnInit()
int OnInit()
{
// License verification - blocks execution if invalid
if(!VerifyLicense("YOUR_API_KEY", ""))
{
Alert("License verification failed. Please contact support.");
return INIT_FAILED;
}
// Your existing OnInit code below...
return INIT_SUCCEEDED;
}MQL5 Version
#import "LicenseShield.ex5"
bool VerifyLicense(string vendorId, string apiKey);
#import
// Add this at the top of OnInit()
int OnInit()
{
// License verification - blocks execution if invalid
if(!VerifyLicense("YOUR_API_KEY", ""))
{
Alert("License verification failed. Please contact support.");
return INIT_FAILED;
}
// Your existing OnInit code below...
return INIT_SUCCEEDED;
}Replace `YOUR_API_KEY` with the API key from your dashboard.
Step 4: Enable WebRequest
Before testing, you need to allow your EA to make web requests:
- In MetaTrader, go to Tools → Options → Expert Advisors
- Check “Allow WebRequest for listed URL“
- Add: `https://licenses.barmenteros.com`
- Click OK
Step 5: Compile and Test
- Compile your EA in MetaEditor (F7)
- Attach to any chart in your demo terminal
- Check the Experts tab for the verification result
You should see something like:
LicenseShield: Verification successful - Trial (7 days remaining)Step 6: Check Your Dashboard
Go back to your LicenseShield dashboard. Click Licenses in the sidebar.
You’ll see a new entry:
| Account | Broker | Status | Last Seen |
|---|---|---|---|
| 12345678 | Name-Demo01 | Trial (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):
- Find their account in your license list
- Look for the Actions column on the right
- Click the Reactivate or Enable button
- Done —the Status updates to “Active” immediately
Revoking Access
If a customer requests a refund or their subscription expires:
- Find their account
- Click the Disable button in the Actions column
- The Status changes to “Disabled“
- Next time their EA starts, it will be blocked
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?
The EA will fail to verify and return `INIT_FAILED`. This is by design—offline piracy is the most common type.
What about Strategy Tester?
Strategy Tester uses account number 0, which LicenseShield automatically allows. Your EA will work in backtests without license issues.
What if LicenseShield is down?
We maintain 99.9%+ uptime. In the rare event of an outage, verified licenses are cached for 24 hours. New verifications will fail, but existing valid licenses continue working.
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:
- Created a LicenseShield account
- Downloaded the MQL library
- Added 3 lines of code
- Enabled WebRequest
- 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].


Leave a Reply