I need to Lock my expert based on my account number and broker

 
I need a help how to lock my EA/Script based on my login account number and one broker only such as "FXDD" ?

example:
my login number in my broker "FXDD" is 12345 , and I want my EA/Script can run only in that login number and FXDD broker.


please help

NOTE:
better if you can give me an example of one EA and script that contains about this and how to put it -> because I'm a newbie and need a help to lock my EA/Script
 

So why exactly do you want to do that ?

 
Marco vd Heijden:

So why exactly do you want to do that ?

I have to give it to a friend and don't want to him to sell it ..
 
You can give him the inverstor-password. With this access you can only watch but not act.
 
Carl Schreiber:
You can give him the inverstor-password. With this access you can only watch but not act.
I want to apply the EA on his account . but only on his account number and broker
 

Example for MT4 EA:

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
{
   int AccountLists_AcceptData[];
   int number_of_accounts = 3;
   ArrayResize(AccountLists_AcceptData, number_of_accounts);
   AccountLists_AcceptData[0] = 14320579; 
   AccountLists_AcceptData[1] = 2009407; 
   AccountLists_AcceptData[2] = 609114; 
   
   bool isAccountNumberOK = false;
   for (int i = 0; i < number_of_accounts; i++)
   {
      if (AccountNumber() == AccountLists_AcceptData[i])
      {
         isAccountNumberOK = true;
         break;
      }
   }

   if (!isAccountNumberOK)
   {
      Print("License is not authorized! Contact Mohamed Abdelwaged");
      return(INIT_FAILED);
   }
   else
   {
      return(INIT_SUCCEEDED);
   }
}
 
Anton Nel:

Example for MT4:

thanks too much Anton

however the print order

Print("License is not authorized! Contact Mohamed Abdelwaged")

did not appear when I try it on another account number not listed and the EA terminated 

another thing how can I specify the Broker to such as "FXDD"

 
Print("Name of broker: " + AccountCompany());
if (AccountCompany() != "FXDD")
{
  return(INIT_FAILED);
}
 
Anton Nel:
It Works .. really appreciated .... ♥ 
 

int OnInit() {
{
   int AccountLists_AcceptData[];
   int number_of_accounts = 3;
   ArrayResize(AccountLists_AcceptData, number_of_accounts);
   AccountLists_AcceptData[0] = 1231; 
   AccountLists_AcceptData[1] = 2342; 
   AccountLists_AcceptData[2] = 2323; 
   
   bool isAccountNumberOK = false;
   for (int i = 0; i < number_of_accounts; i++)
   {
      if (AccountNumber() == AccountLists_AcceptData[i])
      {
         isAccountNumberOK = true;
         break;
      }
   }

   if (!isAccountNumberOK)
   {
      Print("License is not authorized! Contact Mohamed Abdelwaged");
      return(INIT_FAILED);
   }
   else
   {
      return(INIT_SUCCEEDED);
   }
}


should put it this way? hope you can help, it does not work for me

 
markpinlac:
...

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button