Loading…

Trial And Licensing Toolkit

This toolkit demonstrates the honest mechanics of MQL4 trial and licensing code: a trial start time recorded per account number via a namespaced GlobalVariable, a small offline key-derivation formula (account number plus a salt, mixed through a non-cryptographic FNV-1a hash) that a seller can compute keys from without any server, and feature flags that combine an explicit on/off switch with the trial/licence state. It is published with the limitation stated as plainly as possible, because most "licensing" CodeBase submissions do not: client-side logic inside a downloadable, readable, decompilable MQL4 file cannot be turned into real copy protection. Every check here executes on the END USER'S OWN terminal, using code the end user's own terminal has to be able to run - which means it can also be read, patched around, or have the trial's GlobalVariable deleted by hand from the terminal's Global Variables window at any time. The salt shipped in this public CodeBase submission is a placeholder specifically because a "secret" published to everyone who downloads the file is not a secret; a seller who wants a workable version of this changes the salt in their own private build before distributing it to buyers, and even then a sufficiently motivated buyer can extract it from the compiled .ex4 with publicly available MQL4 decompilers. What this DOES genuinely provide is a deterrent against the casual case (an ordinary user who is not trying to bypass it) and an honest, reusable pattern for binding a trial window to an account and gating features on its state - useful building blocks, not a lock. Notes and limitations - THIS IS NOT COPY PROTECTION. Any user with the compiled .ex4 can delete the trial's GlobalVariable by hand (Terminal menu -> View -> Global Variables), and any user with the source (or a decompiled copy) can bypass the licence check entirely by editing the code. No amount of cleverness inside a single downloadable MQL4 file changes this - it is a structural limit of client-side checks, not a bug in this implementation. - MQL4 global variables that go untouched for roughly 4 weeks are auto-deleted by the terminal itself. If the trial-tracking program is installed and then left dormant (not run once) for over a month, its trial-start record can be silently removed by the terminal, and the next run appears to start a brand-new trial. Calling TrialGetStatus() regularly (every run) re-touches the variable and avoids this in normal use; a program that is rarely run is the case where it bites. - The trial is bound to (terminal data folder) x (account number). A fresh terminal installation, a different account, or a copied/reset data folder each gets its own independent trial with no shared state - there is no cross-terminal or server-side record. - The FNV-1a mix used for key derivation is a fast, well-distributed NON-CRYPTOGRAPHIC hash chosen because MQL4 has no built-in cryptographic primitive. It is adequate for "does this key match the formula", never for anything that must resist a determined attacker reversing the salt from observed keys. - The shipped InpLicenseSalt default is published in this public CodeBase submission and therefore protects nothing by itself - it exists to show the mechanism running. Change it in a private build before using this for a real product, and understand that even a changed salt is only ever recoverable-with-effort from the compiled binary, not truly secret.

Script · MT4 · v1.0 · Free

About Trial And Licensing Toolkit

Trial And Licensing Toolkit is a script for MetaTrader 4. It has 5 settings, such as Program name, Trial days and License salt. MQL source code included.

Files in the download: TrialLicensingToolkit.mqh, TrialLicensingToolkit.txt, TrialLicensingToolkitDemo.mq4.

Settings

SettingDefaultWhat it does
Program nameTrialLicensingToolkitDemoProgram name the trial/licence is bound to
Trial days14Trial length in days
License saltDemoSalt-ChangeMeLicence key salt (CHANGE before real use)
Entered keyOptional: paste a key here to test validation
Reset trial after demofalseDelete the trial record after running (keeps repeat testing clean)

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Bitcoin & Crypto · MT4 Script · MQL4 Source Code

MQL4 & MQL5 scripts · PolyMaria