Case study · Trading software · Security engineering
Licensing that protects paid MetaTrader indicators, without making customers type a serial key
I designed and shipped a licence system for my own trading-software business, iTradeAIMS. The server decides who may run each product. The customer's computer only proves it is allowed. Customers activate with one click from their member dashboard.
- Role
- Owner, architect, lead developer
- Timeline
- May 2026 – present
- Status
- Live with paying customers since June 2026
- commits on the licence server
- 841
- written design decisions
- 31
- automated test files
- 170
- crypto test vectors pass in CI
- 15/15
- DLL builds: 64-bit MT5 and 32-bit MT4
- 2
The problem
Why this needed building
What was wrong with the usual approach
- Serial keys get shared, pasted into forums, and lost by customers. They also create support tickets.
- Compiled MetaTrader code can be decompiled, so a check that lives only inside the indicator can be removed.
- Locking to "this PC" is weak: hardware hints can be faked and break when customers upgrade.
What the business needed
- Only paying members can run a product, on a limited number of installs.
- Access can be revoked after refunds and cancellations.
- Activation simple enough that it doesn't flood support.
- Products keep working through short internet or server outages.
Architecture
How it fits together
Select a box to see what it does, or pick a journey and press Play to follow it step by step.
Trust boundary: nothing on the customer's PC is trusted. It must prove itself to the server every time.
Each box is a part of the system
Click one to read what it does and why it was built that way.
Key decisions
What I chose, and what I rejected
Each one is a written decision record in the repository.
No serial keys: activation by one-time fileUX + security
Customers click Activate in their dashboard and open a small file. No key is shown or typed.
Rejected: serial keys (a secret that sits in customers' hands forever and causes copy-paste support work); building a custom installer per customer (heavy infrastructure for little gain). A device-code flow is kept for the future.
The server decides, the client only provesArchitecture
Entitlement, install limits and revocation live only on the server. Each install gets its own credential and signs every request with it, including a timestamp and a single-use number so recorded requests can't be replayed.
Rejected: trusting hardware fingerprints as identity, and relying on obfuscated code. Compiled MetaTrader code can be reversed, so the real protection is the server plus the signature chain.
Signature checks in a small C++ libraryEngineering
A ~200-line C++ wrapper around Windows' built-in cryptography verifies licences, built in CI for both MT5 (64-bit) and MT4 (32-bit).
Rejected: doing RSA maths in pure MQL5. I proved it could work, but it was hundreds of lines of custom big-number code, which is harder to audit than a thin wrapper over the operating system.
Single use is enforced when the token is spent, not when it's downloadedSecurity
Downloading the activation file is harmless and can be retried, which helps customers with flaky downloads. The token is burned only when the indicator uses it, inside a signed request.
Rejected: one-download links, which broke for real customers (browser quirks, retries) and added no security.
One delivery path, made reliableProduct
Activation happens only through the logged-in dashboard, because the login is the customer's identity. I chose to make that one path robust instead of adding an email path.
Rejected: emailed activation links, an unauthenticated second channel that would not have fixed the real faults behind the 'activation doesn't work' reports (see the problems below).
Merging to main deploys to productionOperations
Every merge is promoted automatically and stamped with its commit, so 'what is live?' always has an answer.
Rejected: a manual production button. It was meant as a safety gate, but in practice it let staging and production drift apart without anyone noticing.
In production
Problems found in production, and how I fixed them
The system went live, real customers used it, and real problems showed up. Each fix came from evidence: server audit logs, client logs, or reading the code.
Request storms when traders changed timeframePerformance
Symptom
Server logs showed bursts of licence checks every time a trader switched timeframe or chart template.
Diagnosis
MetaTrader restarts indicators on many purely cosmetic events, and the indicator was re-checking with the server each time, on every open chart at once, even though it already held a valid licence.
Fix
Licensing was decoupled from the chart lifecycle. The indicator checks its saved licence locally first, and licence lifetime was raised from 2 minutes to 6 hours, which safely removed almost all of the calls.
Genuine requests rejected as 'replays'Security
Symptom
Some valid customers were refused with a duplicate-request error.
Diagnosis
The first idea was to make the server more lenient. Reading the client code showed it never reuses a request number. The real cause was two charts generating the same 'random' number in the same millisecond.
Fix
Fixed at the source: the number generator in the client. The server's replay protection stayed strict, and no security hole was opened.
Paying customers with nothing to activateData integrity
Symptom
Reports said 'activation doesn't work'.
Diagnosis
Investigation found several separate causes: some memberships were never mapped to a licence, browsers blocked the download pop-up, and the request storms above. The login requirement wasn't the problem.
Fix
Fixed each cause: provisioning mapped correctly, the download started inside the user's click with the right server headers, and clearer sign-in prompts added.
38 of 41 database tables were not transactionalData integrity
Symptom
Code that relied on rollback and row locks wasn't really protected.
Diagnosis
The production database defaulted to MySQL's non-transactional engine. Only the 3 tables that explicitly asked for InnoDB were safe. MySQL accepts transaction commands on the others and silently ignores them.
Fix
Made InnoDB a standing rule, enforced in the code, and converted the affected tables.
The same product bundle defined in two systemsConsistency
Symptom
Bundle members were sometimes granted for life even when the parent membership was time-limited.
Diagnosis
The bundle existed both as a WordPress snippet and as a licence-server rule, with different lifecycles. They disagreed in production.
Fix
The licence server became the only owner of bundles. The WordPress side no longer grants entitlement.
Nobody could tell what version was liveOperations
Symptom
Production looked 'out of date', which was indistinguishable from a real bug.
Diagnosis
A build-identity endpoint already existed, but the pipeline never filled it in, so it always reported 'unstamped'.
Fix
Every build is now stamped with its commit and run, and production is deployed on merge.
Method
How I built it
- 1
Every important choice is a short written decision record, so the system can be explained and changed safely.
- 2
Work moved through gates: design, test harness, staging with fake customers, then production. Each gate needed evidence before the next one opened.
- 3
I used AI coding agents (Claude Code, Codex) under my direction. I wrote the specs, decisions and acceptance tests, then reviewed and verified the output. That let one person build what would normally take a small team.
- 4
Merging to the main branch deploys to production, and every build records which commit it came from, so it's always clear what is running live.
Stack
Technology
- PHP / Laravel
- MySQL
- WordPress + Paid Memberships Pro
- MQL5 / MQL4
- C++ (Windows CNG)
- RSA-PSS-SHA256 signatures
- HMAC request signing
- Inno Setup installers
- GitHub Actions
- Docker
- PowerShell
What this means for your project
If you sell an EA or indicator, I can add server-side licensing to it: activation, install limits, revocation and offline grace. Or I can review the protection you already have.
I also build MT4/MT5 EAs and indicators, and port TradingView scripts to MQL5 with tests that prove the two versions match.
This page describes the architecture only. Server addresses, secrets and customer data are deliberately left out. The source code is proprietary; I'm happy to walk you through the system live on a call.