Download MetaTrader 5

How to protect EA by trading Account

To add comments, please log in or register
Nyan-fx
23
Nyan-fx  

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...  

Carl Schreiber
7299
Carl Schreiber  
One option would be:
if ( TimeCurrent() > TimeLimit ) ExpertRemove();
honest_knave
Moderator
2326
honest_knave  
Carl Schreiber:
One option would be:
if ( TimeCurrent() > TimeLimit ) ExpertRemove();

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.

Tuan Hoang
9
Tuan Hoang  

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);   

honest_knave
Moderator
2326
honest_knave  
Tuan Hoang:

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.

To add comments, please log in or register