Password Protection for Your Indicator/Expert Advisor
Info
The Password Protection for Your Indicator/Expert Advisor is a Expert Advisor for MetaTrader 4 that several methods of protecting your code have been proposed, but they either lacked security, required frequent recompilation, or were overly complex with remote hosts. This article introduces a password verification scheme using MT4's built-in security engine with DES/ECB encryption, eliminating the need for recompilation.
Usage
This tool is typically used for automated trading on major forex pairs and gold.
Platform
This Expert Advisor works exclusively on MetaTrader 4 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL4/Experts folder via File ? Open Data Folder in MetaTrader 4.
How to Install and Use Password Protection for Your Indicator/Expert Advisor
1. Installation: Open the "File" menu, select "Open Data Folder," navigate to MQL/Experts, paste your file, and restart the terminal.
2. Activation: Drag the EA from the Navigator onto a chart, ensure "Allow live trading" is checked in the Common tab, and verify the AutoTrading button is green.
3. Optimization: Right-click your chart, choose "Expert List," click "Properties" to adjust inputs, and save your preferred setup as a set file for future use.
4. Maintenance: Regularly check the "Experts" tab in the terminal window to monitor trade logs and potential execution errors.
Frequently Asked Questions
Q: Why is my EA not opening trades? A: Check the "AutoTrading" button, ensure "Allow live trading" is enabled, and verify your broker allows automated trading on your account type.
Q: Can I run multiple EAs on one chart? A: No, each chart can only host one active EA; however, you can open multiple charts for different currency pairs to run several EAs.
Q: What does the "smiley face" icon mean? A: A smiley face in the top-right corner of the chart indicates the EA is successfully running; a frowny face means it is disabled.
What this tool does
Several methods of protecting your code have been proposed, but they either lacked security, required frequent recompilation, or were overly complex with remote hosts.
Typical Use Case
This Expert Advisor excels in automated trading and technical analysis on MetaTrader 4.
Compatible Platform & Setup
This Expert Advisor works on MetaTrader 4. Place the file in the MQL4/Experts folder and restart the terminal.
Description & Settings
Related: master mm droid: advanced deposit protection - another powerful expert for MetaTrader 4 traders.
Several methods of protecting your code have been proposed, but they either lacked security, required frequent recompilation, or were overly complex with remote hosts.Also recommended: DroneOx Equity Guardian: Automated Equity Protection - similar expert with strong performance on MetaTrader 4.
This article introduces a password verification scheme using MT4's built-in security engine with DES/ECB encryption, eliminating the need for recompilation.
A risk assessment is crucial. If you're dealing with millions of dollars, this scheme might not suffice. However, if the risk is limited to potential code theft, this solution offers a robust defense.
Two source files are provided:
- 'password_check': Verifies the password in the 'password' input parameter. If incorrect or offline, it displays a message, unloads the expert, and returns 'init_failed'.
- 'password_generate': Generates a password based on the client's name and account number. This password is provided to clients, ensuring secure access.
The process involves:
- Defining an input string for the indicator/expert advisor.
- Adding code in the 'init()' function to check the password and display relevant messages.
- Encoding the client name and account number with a DES key, converting to Base64, and comparing with the entered password.
This scheme allows for multiple accounts per client by adjusting the 'client' string. The longer the 'client' variable, the longer the encrypted password.
The 'password_generate' code follows a similar process, generating a password based on client details. Ensure password consistency between 'password_check' and 'password_generate' functions.
This method provides a balance between security and convenience, protecting your indicator/expert advisor without recompilation or complex server-side validation.
You may also like: expert adviser licence protection template - excellent alternative for expert users on MetaTrader 4.
Source Code
#property copyright "robotfx"
#property link "https://robotfx.org"
#property version "1.00"
#property strict
extern string password;
int init()
{
string client = null;
if(isconnected()) client = accountinfostring(account_name) + " / " + doubletostr(accountinfointeger(account_login), 0);
if(!password_check(client))
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.