Download MetaTrader 5
To add comments, please log in or register
Launch your trading signal and add account monitoring!
NHShine
10
NHShine 2016.11.15 04:18 

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
5962
Carl Schreiber 2016.11.15 10:22  
One option would be:
if ( TimeCurrent() > TimeLimit ) ExpertRemove();
honest_knave
969
honest_knave 2016.11.15 10:48  
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 2016.11.19 17:11  

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
969
honest_knave 2016.11.20 09:30  
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