Download MetaTrader 5
To add comments, please log in or register
Find out how to use widgets at MQL5.community
linux
17
linux 2009.03.04 15:52 

Hello,

I got my EA coded via a friend, how can I limit it to an account no. or a broker company, so if it is launched on another account number or another broker company, it doesn't work, as I want to give it to someone but don't want to allow him to sell it.

Brian Dee - Random Trader
1764
Brian Dee - Random Trader 2009.03.04 16:52  

Linux

> I got my EA coded via a friend

Better look after that one ;)

Something like this will get you started - OTTOMH :)

//+------------------------------------------------------------------+
//|                      www.selectfx.net                            |
//+------------------------------------------------------------------+



extern string UserInfo = "=== License Settings ===";
//#######################################
extern int LicenseEndYear=2009;
int RealLicenseEndYear=2009;
extern int LicenseEndMonth=11;
int RealLicenseEndMonth=11;
extern int LicenseAccount=1234;
int RealLicenseAccount=1234;
//#######################################




//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {


// Check each tick section START


  if (Check_License()!=0) return(0);

// ===== Your code stuff ========








// ===== Your code stuff ========

// Check each tick section END


   return(0);
}





int Check_License()
{
     if(Year()>RealLicenseEndYear)
     {
      Print("License Expired on Year: ", RealLicenseEndYear, " for this EA!");
      Alert("License Expired on Year: ", RealLicenseEndYear, " for this EA!");
      return(1);  
     }
     
     
     if((Year()==RealLicenseEndYear) && (Month()>RealLicenseEndMonth))
     {
      Print("License Expired at Month: ", RealLicenseEndMonth, " for this EA!");
      Alert("License Expired at Month: ", RealLicenseEndMonth, " for this EA!");
      return(2);  

     if(AccountNumber()!=RealLicenseAccount)
     {
      Print("Account Number: ", AccountNumber(), " not licensed for this EA!");
      Alert("Account Number: ", AccountNumber(), " not licensed for this EA!");
      return(3); 

     }
     
   return(0);
}




Good Luck

-BB-

linux
17
linux 2009.03.04 18:01  
BarrowBoy:

Linux

> I got my EA coded via a friend

Better look after that one ;)

Something like this will get you started - OTTOMH :)

Good Luck

-BB-

Thank you, but I can't still figure it out for the account no. or broker name

Brian Dee - Random Trader
1764
Brian Dee - Random Trader 2009.03.04 23:27  

Account number is in the example above

Broker name is found by using AccountServer()

linux
17
linux 2009.03.05 05:01  
BarrowBoy:

Account number is in the example above

Broker name is found by using AccountServer()

Yes, just got it, thank you so much, I'll be trying it.

Pilot65
670
Pilot65 2009.03.05 22:46  

...Or just do it super simple:

int start() {
//------ Authenticate --------------
if (  AccountNumber()!=123454321)
   {
    Alert("Unlicensed copy!");
   return;
   }
//----------------------------------

//Your normal code starts here
linux
17
linux 2009.03.07 08:19  
DayTrader:

...Or just do it super simple:


Thank you so much, that's an easy way :)

Sajid Mohommod
50
Sajid Mohommod 2014.05.19 17:52  

how to set " Your Account Is Approve " in Comment ( Big Text )


int start() {
//------ Authenticate --------------
if (  AccountNumber()!=123454321)
   {
    Alert("Unlicensed copy!");
   return;
   }
//----------------------------------

//Your normal code starts here
/
To add comments, please log in or register