Download MetaTrader 5

EA locking

To add comments, please log in or register
Amin EL-HAKIM
598
Amin EL-HAKIM  
Hello

I'm using the following part of code to lock a certain EA


//Date Lock
bool use_demo=True;
int demo_year=2015;
int demo_month=7;
int demo_day=30;
//Account Number Lock
int acc_number=11223344;

int start() {
  //demo
if(use_demo)
{
if((Year()>demo_year || (Year()==demo_year && Month()>demo_month) || (Year()==demo_year && Month()==demo_month && Day()>=demo_day)) || IsTesting())
{
Alert("License Expired, Contact Seller: example@example.com");
return(0);
}
}

  //acc number
  if(acc_number!=0 && acc_number!=AccountNumber())
  {
  Alert("EA Not Licensed For Your Account Number, Contact Seller: example@example.com");
  return(0);
  }

My question is how can I output an ex4 file to work on several accounts instead of producing 1 ex4 file for each account ie: 11223344, 124578, 458789, 87859.
Osama Shaban
1687
Osama Shaban  

I'm using the following code ...

//===============================================
int      LiveAccountNo = 1234567890;
datetime   Demo_Expiry = D'2015.09.30 00:00';
//===============================================

In the Start() ... Type the following ...

   if(!IsDemo() && AccountNumber()!=LiveAccountNo){
      Comment("The EA is not licenced to this live account ...",
              "\nContact .......@gmail.com to get a license ...");
      return(0);        
   }
   
   if(IsDemo() && TimeCurrent()>Demo_Expiry){
      Comment("The EA Demo test copy has expired...",
              "\nContact .......@gmail.com to renew the license ...");
      return(0);        
   } 

You can play around the live or demo expiry date ...

 

For using the EA for multiple live accounts ... use ...

   if(!IsDemo() && (AccountNumber()!=LiveAccountNo1 || AccountNumber()!=LiveAccountNo2 || AccountNumber()!=LiveAccountNo3)){
      Comment("The EA is not licenced to this live account ...",
              "\nContact ........@gmail.com to get a license ...");
      return(0);        
   }
To add comments, please log in or register