You are on page 1of 21

MTLicense

Protect Your MQL Apps From Piracy.

© 2018 dayarathna.com. All rights reserved. Rev 3, 03/19


Contents
1. Introduction 02

1.1. How it works 03

1.2. Using Licensed MQL Application on MT4 06

2. MTLicense Generator Application Dialog 08

2.1. Generate New Licenses 09

2.2. Managing Licenses 11

2.3. View Licenses 12

2.4. Modify Licenses 13

2.5. Delete Licenses 14

2.6. Search Licenses 15

2.7. Test License/License Text Validation 16

3. Example Licensing Scenarios 17

3.1. Creating licenses for beta software 17

3.2. Using evaluation licenses 17

3.3. Using an evaluation license which is replaced with full license upon purchase 17

3.4. Creating licenses for beta version of your MQL4 application 18

3.5. Limiting activations to a specific list of MT4 accounts 18

3.6. Creating software subscription licenses 18

4. Integrating MTLicense in Your MQL Application 19

5. Deploying Your MQL Application 20

6. FAQs 21

1
MTLicense User Guide
Introduction
MTLicense is a software licensing library which allows you to implement licensing, copy-protection and activation
capabilities into your MT4 expert advisors, indicators and scripts. It provides you all the tools to create and validate
licenses for your software. MTLicense uses the latest and Strongest AES cryptographic technology to ensure that your
application is protected.

Features

• Create evaluation or trial versions of your script/EA/Indicator


• Create Trial Keys that expire on a specific date
• Easily turn your trial version into a fully licensed version using a new license key
• Lock license keys to a specific account(s)
• Lock license keys to a specific currency pair(s)
• Embedded license keys database
• Strong license encryption using AES encryption techniques

User Interface

MTLicense has a full featured User Interface with license generator, Validator and database functions.

Royalty Free

MTLicense is licensed per developer. If you have a license*, you can build as many applications as you want and
distribute them without paying any further royalties.

Strong Encryption

MTLicense uses latest AES encryption techniques to create and verify license keys which make it hard for a cracker to
create any keygens.

Compatibility

The whole Licensing solution is built based on MQL4 language without any external dependencies in order to provide
maximum compatibility. Even for Wine based Linux/Mac MT4 installations.

2
MTLicense User Guide
How it works
1. The MT4 account number, email and other requirements that user should want to use in the program should
be given to license issuer to purchase the license, via either mail or phone. (This may include additional steps
such as purchase, one-time payment or subscription.)

Ex: MT4 Account No: 123456789


Email: jhondoe@email.com
Currency pairs expected to use: EURUSD, GBPUSD

2. At the license issuer side, there is a license issuer program to issue the license based on the MT4 account
numbers and those features the user has bought.

3
MTLicense User Guide
3. License Issuer generates the license key based on the MT4 account number and other license options.

4. After license is generated, license issuer should send back the license key to the user. This is also an offline
step, maybe by e-mail, mail or text file.

4
MTLicense User Guide
5. User enters the license key into the EA’s/Indicator’s or script’s input window to activate the app.

6. MT4 Application verifies the license and startup

5
MTLicense User Guide
USING LICENSED MQL APPLICATION ON MT4

• Open Metatrader, and then open the data folder by selecting File->Open data folder
• Copy MTLicenseLib.ex4 file to the ‘MQL4\Libraries’ folder

• If your MQL4 application is an indicator:

Copy your .ex4 indicator to the ‘MQL4\Indicators’ folder

• If your MQL4 application is an Expert Adviser:

Copy your .ex4 EA to the ‘MQL4\Experts’ folder

• If your MQL4 application is a Script:

Copy your .ex4 script to the ‘MQL4\Scripts’ folder

• If there are any .dll files available with your MQL Application, Copy them to the / MQL4/libraries folder (Only if
your MQL Application is using .dll files)
• Enable .dll files inside MT4 by selecting Tools->Options, select the ‘expert advisors’ tab, and checking ‘Allow DLL
Imports’ (Only if your MQL Application is using .dll files)

6
MTLicense User Guide
• Refresh MT4 by closing, and re-opening it, or select indicators in the navigator->right click->select ‘refresh’
• Select, or open the price chart you want to load the MQL Application onto, then double click, or click-and drag
the MQL Application (EA, Indicator or script) to apply it to the chart.
• Check the expert tabs for any errors that occur on MQL Application load, and act accordingly.

7
MTLicense User Guide
MTLicense Generator - User Interface Reference
The MTLicense Generator is the main application which you will use to generate codes for your licensed MQL software.

The main application dialog contains the following UI elements:

Validate License
Button
Search Button

New License Button

Grid Groups

Saved Licenses Grid View

8
MTLicense User Guide
GENERATE NEW LICENSE

Whenever a customer purchases your software, you will generate a new license and send it to the customer. This can
be done in following ways:

Click on the “New License…” button on the main application dialog. New license Generator window will appear.

In the “New license Generator” window, simply specify one or more license settings (for example: Expire Date, or Lock
to Accounts)

Click Generate button. The generated code will be displayed in the bottom textbox.

9
MTLicense User Guide
If you click on the “save” button, newly generated license key and the user information will be added to the database.

Note: The License Management functionality is only for keeping a record of all generated licenses and their
corresponding license settings. This database is never used during license validation.

The New License generator dialog contains the following UI elements:

• Name/Email fields are required. They will not include with the license key.
• Expire Date:

When checked, allows you to specify an absolute date after which the license validation fails.

• Lock To Accounts:

When checked and specified the MT4 accounts, locks the license to the specified MT4 accounts. So that the
new license can only be used on that MT4 accounts.

Specify the maximum number of MT4 accounts that the license can be activated on. This allows you to have
one license key but still allowing usage on different Accounts/machines/users.

• Lock to currency pairs:

When checked and specified, you can limit license to a specific currency pairs. So your MQL application will run
only on that of currency pairs.

• Minimum Account Balance:

When checked, license validation fails if the current accounts balance less than the specified value.

• Disable Demo trading:

When checked, your MQL application will run only on the real accounts.

• Disable live trading:

When checked, your MQL application will run only on the Demo/ Contest accounts.

• Disable back testing

When checked, end user will be blocked from the back testing on the MT4 platform.

• Show License Info on MT4

MTLicense includes a ready-made ‘license information panel’ which you can use to display to your users. When
checked, License information will display on the chart.

• Limit to Timeframes:

When checked, your MQL application will run only on the selected timeframes.

10
MTLicense User Guide
MANAGING LICENSES

The database features allows you to add generated license codes and their corresponding license settings to a
database. It is useful for maintaining a record of all licenses generated which can be used for CRM, record-keeping,
data-mining, etc.

To use the license management functionality:

Whenever new licenses are generated, Click on the “save” button. License and user data will be added to the database.

VIEW LICENSE

In the main window, simply double click on the record in the grid view or click on the “view” link on the selected record,

Click on ’view’ link

Double click on the record

And the system displays a dialog containing all the information of the specific license key in a detailed window.

11
MTLicense User Guide
MODIFY LICENSE

In the “New license Generator” window, simply double click on the record in the grid view or click on the “view” link on
the row, (See “View License") and the system displays a dialog containing all the information of the specific license key
in a detailed window as shown in picture below.

In this window, you can change any of the Evaluation settings of the License record. When you finish editing the License
information,

• Click the Generate button. Send the updated license code to your customer.
• Press the 'Save' button to save updated License key into the database.

“Copy” and “Save text file” buttons will allow you to copy the generated license key to the clipboard and to save the
generated license key to a text file.

12
MTLicense User Guide
DELETE LICENSE

In the “New license Generator” window, click on the “delete” link on the selected record.

click on the “delete” button

Then confirmation window will appear.

Choosing “Yes” removes the License key from the database.

13
MTLicense User Guide
SEARCH LICENSE

In the main window, click on the “search” button.

Click on the “Search” button

Then search box will appear. By typing into the search box, the content of the main view window is updated to reflect
the search term. Any license record that has a value that contains the current string in the search box will still be visible
in the main data grid view. If no license information match the string provided, the main data grid view will appear
empty.

Press “clear” button to reset the search results.

14
MTLicense User Guide
TEST LICENSE/LICENSE TEXT VALIDATION

License validation is a procedure of verifying that the software license is valid. When a license key is validated, the
returned license has the same settings as that of the profile which was active when the serial was generated.

You can use the "validate License..." window to test a license key that has been provided to you.

• Enter or paste the license key into the License textbox.


• License key status message should appear. If there is a problem with the license key, the software would
display an appropriate error message instead.

15
MTLicense User Guide
Example Licensing Scenarios
CREATING LICENSES FOR BETA SOFTWARE

In certain cases, such as when distributing a beta version of your software, you might want the license to expire on an
absolute date. To specify a date of expiry, use New License Generator page as follows:

• Check the Expire Date checkbox and specify the date when you want the license to expire. (You can select from
the templates dropdown or use a custom date)
• Click the Generate button. Send the generated license code to your customer.

USING EVALUATION LICENSES

You can let your MQL app to work only until a certain date. When demo period expires, the MQL app will no longer
work and user will have to ask you for fully licensed version of the MQL app.

The workflow is as follows:

• In the New License Generator page, check one or more evaluation settings discussed above and specify the
corresponding limit (for example, Expire Date to 1 Month).
• Click the Generate button. Send the generated license code to your customer.

USING AN EVALUATION LICENSE WHICH IS REPLACED WITH FULL LICENSE UPON PURCHASE

This scenario entails using an evaluation license (limited by days, executions, etc.) with the evaluation version of your
software. When a customer purchases your program, you will generate a new license without any evaluation limits and
send it to him.

In the New License Generator page:

• Generate an evaluation license using limits as per your requirements. Save this for later use below.

When customer purchases your program:

• Generate a license without any evaluation limits but which can have other limits as per your requirements (like
Lock to accounts, Minimum account balance, etc.)
• Send the generated license code to your customer.

16
MTLicense User Guide
CREATING LICENSES FOR BETA VERSION OF YO UR MQL APPLICATION

This scenario entails using an evaluation license (limited by days, executions, etc.) with the evaluation version of your
software.

• When a customer purchases your program, you will generate a new license without any evaluation limits and
send it to him.

LIMITING ACTIVATIONS TO A SPECIFIC LIST OF MT4 ACCOUNTS

In some scenarios, you may wish to limit license to a specific list of MT4 accounts. You can achieve this as follows:

From Your Software

• To generate an account-locked license, you need the MT4 account number(s) of the target MT4 account to
which to lock the license to. You can get this as follows:
• Ask user to send to you (via email or another way) the account number(s) that user should want to use the
program
• In the License Generator page, check the Lock to Accounts checkbox and specify the MT4 account numbers you
have received from your user.
• Click the Generate button and send the generated account-locked license code to your user.

CREATING SOFTWARE SUBSCRIPTION LICENSES

Subscription licenses can be used to create subscriptions for your software. Subscription licenses can be created by
specifying a date of expiration for the license. When the license expires, customer will ask you to retrieve a new
expiring license (1 month, 14 days, or any other period you desire).

The workflow is as follows:

• User makes initial purchase OR user makes renewal purchase


• In the License Generator page, Check the Expire Date checkbox and specify the date when you want the license
to expire. (You can select from the templates dropdown or use a custom date)
• Click the Generate button. Send the generated license code to your customer.

17
MTLicense User Guide
Integrating MTLicense in Your MQL Application
Note: This section is only applicable if you bought the “License Template” feature.

When developing a secured EA/Indicator, reference the ‘MTLicenseLib.ex4’ library. There are no other dependencies
and this is the only library that needs to be referenced from your MQL application.

End-user can specify the license Key via the ‘LicenseKey’ extern variable.

Use the ‘CheckLicense ()’ method to validate any license code. If the check/validation fails for some reason, library will
automatically call the ‘return(INIT_FAILED)’ method with a pre-defined error message.

It’s that simple to start using MTLicenseLib.ex4 library for the licensing of your MQL application. An MQL Template file
included to provide quick code sample which can be used to quickly create a License Protected MQL application.

If the license was validated successfully, the MTLicenseLib.ex4 library will return ‘MTLicenceInfo’ object which include
the features specified by the license which you can use to customize your MQL application in any way you wish.

• MTLicenceInfo.IsValid

Return type: bool, Read Only


Returns the cached result of the validation. If license validation is successful, IsValid() will return true.

• MTLicenceInfo.AllowedAccounts

Return type: string, Read Only


Returns allowed account numbers (separated by commas).

• MTLicenceInfo.AllowedCurrencyPairs

Return type: string, Read Only


Returns allowed currency pairs (separated by commas).

• MTLicenceInfo.ExpireDate

Return type: string, Read Only


Gets the date when the license expires in default date format. If not specified, this will return an empty string.

• MTLicenceInfo.AllowedTimeFrames

Return type: string, Read Only


Returns allowed timeframes (separated by commas). If not specified, this will return an empty string.

• MTLicenceInfo.MinimumBalance

Return type: int (1 or 0) , Read Only


Get the minimum accounts balance which specified by the license. If not specified, this will return 0.

• MTLicenceInfo.DisableLiveTrading

Return type: int (1 or 0) , Read Only


Gets whether the live trading has been disabled in the license. If not specified, this will return 0.

18
MTLicense User Guide
• MTLicenceInfo.DisableDemoTrading

Return type: int (1 or 0) , Read Only


If demo trading disabled by the license, this will return 1. If not specified, this will return 0.

• MTLicenceInfo.DisableBacktesting

Return type: int (1 or 0) , Read Only


If backtesting disabled by the license, this will return 1. If not specified, this will return 0.

• MTLicenceInfo.ShowLicenseInfo

Return type: int (1 or 0) , Read Only


Gets whether the ‘show license information panel to the user’ is present in the license. If not specified, this will
return 0.
.
Note: The MTLicense includes a ready-made ‘license information panel’ which you can use to display to your
users. Every Template license of MTLicense comes with full source code for the Evaluation Info dialog which
you can use to customize and/or localize it in any way you wish.

Deploying Your MQL Application


To deploy your protected MQL Application, you need to distribute the ‘MTLicenseLib.ex4’ file with your protected MQL
Application. ‘MTLicenseLib.ex4’ is the licensing runtime containing the license validation classes. This file must be
copied to the ‘\MQL4\Libraries’ folder on the target computer. ‘MTLicenseLib.ex4’ does not have any dependencies, so
it is the only file that needs to be redistributed with your protected MQL Application.

19
MTLicense User Guide
FAQs
We invite you to check out our answers to frequently asked questions.

WHAT IS MTLICENSE?

MTLicense is a powerful yet easy to use 100% MQL based library for licensing MQL applications using user friendly and
secure license keys based on latest AES encryption techniques.

YET, WHAT IT IS DOING EXACTLY?

MTLicense make it easy to developers and software companies to create the licensing part of their MQL applications.

WHAT IS MTLICENSE GE NERATOR?

MTLicense User Interface is an executable program (windows .exe) which helps you to create license Keys, validate
license Keys and manage license Keys.

CAN LICENSE CODES HAVE MULTIPLE LIMITS AND/OR SETTINGS?

Yes, when generating license codes via MTLicense Generator, you can specify zero, one or more than one license limits
or settings in any combination. For example, you can generate a license code having features as well as the "Expire
Date" Or you can generate a license code having the "Lock To Accounts", "Disable Live Trading" as well as the "Limit To
Timeframes" limits. During license validation all the limits will be checked one after the other.

HOW MANY TIMES CAN I REINSTALL THE SOFTWARE ON THE SAME COMPUTER?

There is no limit on how many times you can reinstall the MQL application on the same computer. You can do that any
time you want. However, the license must be validated successfully each time.

IT IS POSSIBLE TO BREAK A 256 BIT ENCRYPTED SERIAL KEY PRODUCED BY MTLICENSE?

AES-256 (Advance Encryption Standard) with 256 bit key is the most advance cryptographic algorithm till date and not
has been broken yet. And it will cost decades or billion dollar super computer.

CAN I USE MY OWN STRINGS AS A PRIVATE KEY?

All the private keys are random strings. To make customization, you'll need to buy the full source code.

WHY MY GENERATED LICENSE KEYS ARE SO LONG?

Most likely because of too much locked accounts or locked currency pairs Info, try to minimize it.

20
MTLicense User Guide

You might also like