If you sell or plan to sell an Expert Advisor, you need a license key system. Without one, your EA can be freely copied, shared on forums, and used by anyone who gets hold of the file. A license key system is what separates hobbyist developers from professional EA businesses.
This guide explains how MetaTrader license key systems work, what makes a good one, and how to add one to your EA without becoming a backend developer.
A MetaTrader license key is a unique string of characters issued to a specific customer that your EA validates before it starts trading. Think of it like a software serial number, but designed specifically for the MetaTrader environment.
When a customer purchases your EA, they receive a key. When they attach the EA to a chart, the EA sends that key to a validation server. The server checks whether the key is active, not expired, and assigned to the correct account. If everything checks out, the EA runs. If not, it shuts down with an error message.
The simplest approach is to hardcode a list of valid keys inside your EA and check against them locally. This requires no server and is easy to implement, but has a critical flaw: anyone who decompiles your EA or reverse-engineers the logic can extract the valid keys or bypass the check entirely.
A much more secure approach is to have your EA call an external API on every startup. The server holds all the logic for key validation, expiry checking, and account binding. Since the validation happens server-side, there is nothing in the EA file that can be reverse-engineered.
Account binding is what makes license keys truly powerful. Instead of just validating a key string, the server also checks that the key is being used on the correct MetaTrader account number.
When a customer activates their license, they submit their broker account number. The server records the binding: this key is only valid for account 12345678. If someone copies the key and tries to use it on a different account, the validation fails.
This single feature eliminates the most common form of EA piracy: one customer sharing their license with five friends.
Adding license validation to an existing EA typically requires adding a function call in OnInit(). A well-designed license API requires minimal code changes:
The ValidateLicense function makes an HTTPS call to the license server, passing the key and account number. The server returns a simple pass or fail. The whole integration is typically 20 to 30 lines of code.
You could build your own license server. It requires a web server, a database, an API layer, key generation logic, expiry handling, a customer dashboard, and ongoing maintenance. Most EA developers who try this route spend 40 to 80 hours and end up with something that works but is fragile and difficult to maintain.
MTLicense is a purpose-built license management platform for MetaTrader EA developers. It provides the full stack out of the box: server infrastructure, API endpoints your EA can call, a developer dashboard for issuing and managing keys, and a customer-facing portal. You integrate it into your EA in an afternoon.
A well-designed system includes a grace period: if the server cannot be reached, the EA continues running for a defined window (typically 24 to 48 hours) before requiring re-validation. This prevents legitimate customers from being locked out due to connectivity issues.
This is entirely up to you. You can configure your license system to allow one account per license, or multiple accounts at different price points. Many EA sellers charge extra for each additional account, which creates a natural upsell opportunity.
When a subscription expires or is cancelled, the key becomes inactive on the server. The next time the EA checks in, validation fails and the EA stops. No manual action required.
MTLicense gives your MT4/MT5 EA a complete license key system in under an hour.
Get Started Free