← Back to Blog
Tutorial

How to Add License Protection to Your MQL5 Expert Advisor

March 25, 2026 · 6 min read · By MTLicense Team

If you are selling an MQL5 Expert Advisor through the MQL5 Marketplace, your own website, or directly to clients, you need license protection. Without it, every customer can share your EA with anyone. This tutorial walks you through adding hardware-bound licensing in under 10 minutes.

What You Will Need

Step 1: Create Your Account and Product

Sign up at mtlicense.com in 30 seconds with no credit card. Once in, click New Product, name your EA, and copy the Product ID. You will also need your API Key from account settings.

Step 2: Install the SDK

Download LicenseManager5.mqh from your dashboard. Place it in your MQL5 includes folder:

...\MQL5\Include\LicenseManager5.mqh

Step 3: Add Two Lines to Your EA

#include <LicenseManager5.mqh>

int OnInit() {
  if(!LicenseManager::Check("YOUR_API_KEY", "YOUR_PRODUCT_ID")) return INIT_FAILED;
  // rest of your OnInit code
}

Replace the placeholders with your real API key and product ID. Compile as normal. That is it.

💡 That really is all the code

The SDK handles the HTTPS request, sends the account number, parses the response, and returns true or false. Your EA stays clean.

Step 4: Test Before You Ship

Load the EA on a chart without adding your account to the dashboard. It should fail to initialize. Then add your account number as a test license and reload. It should run. This confirms everything works end to end.

Step 5: Issue Licenses to Customers

When a customer pays, log into your dashboard and add their MT5 account number. They are live immediately with no recompile and no file redistribution needed. To revoke, delete their license. Done.

📈 Direct sales means more profit

The MQL5 Marketplace takes 30% commission. Selling directly with MTLicense means you keep 100% of every sale.

Start protecting your MQL5 EA today

Free to start. Takes 10 minutes. No server setup required.

Create Free Account →