One option would be:
You can also check account number using AccountNumber()
Implementing more sophisticated licensing / activation keys is a more advanced topic and maybe not one that a beginner would want to try.
You can also explore using the MetaQuotes Marketplace to control the distribution of your EA.
You can try this:
On the OnInit:
1. Time Limit:
if(TimeCurrent() > TimeLimit) return(INIT_FAILED);
2. Specify trading account:
Check your account number, then use it:
if(AccountNumber() != YourAccountNumber) return(INIT_FAILED);
You can try this:
On the OnInit:
1. Time Limit:
if(TimeCurrent() > TimeLimit) return(INIT_FAILED);
2. Specify trading account:
Check your account number, then use it:
if(AccountNumber() != YourAccountNumber) return(INIT_FAILED);
There can be some problems running these checks in OnInit()
If timeframes aren't changed / the terminal not shut down etc, the EA will continue to run for some time after the expiry date i.e. until OnInit() is next called. Also, the value of TimeCurrent() will not be correct if the terminal is not connected when this code runs.
If the AccountNumber() check runs before the terminal connects to the broker, I think it will return 0 and thus fail.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everyone, I am a beginner MQL4 Programmer. I want to know that how to protect my EA to use specify trading account and how to time limit to my ea.
Please Help me. Thank... Everybody...