Download MetaTrader 5

Lock account number and time limit

To add comments, please log in or register
Suy Kok Yik
246
Suy Kok Yik 2015.09.09 13:05 

Dear Sir,

I need somebody to correct the follow code:

#property copyright " www.OnlyWinnerClick.com "

#property link      "www.OnlyWinnerClick.com" 

const string allowed_broker = "Instaforex Companies Group";

const long allowed_accounts[] = { 61736192, 436290, 646490, 225690, 279260 };

                             

int password_status = -1;



//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

//---

   string broker = AccountInfoString(ACCOUNT_COMPANY);

   long account = AccountInfoInteger(ACCOUNT_LOGIN);

   

   printf("The name of the broker = %s", broker);

   printf("Account number =  %d", account);

   

   if (broker == allowed_broker) 

      for (int i=0; i<ArraySize(allowed_accounts); i++)

       if (account == allowed_accounts[i]) { 

         password_status = 1;

         Print("EA account verified");

         break;

       }

   if (password_status == -1) Print("EA is not allowed to run on this account."); 

    

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---  

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

//---

  if (password_status == 1) 

  {

    // password correct

  } 

  }------------------------ 4 --



datetime allowed_until = D'2016.02.11 00:00'; 

                             

int password_status = -1;



//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

  {

//---

   printf("This EA is valid until %s", TimeToString(allowed_until, TIME_DATE|TIME_MINUTES));

   datetime now = TimeCurrent();

   

   if (now < allowed_until) 

         Print("EA time limit verified, EA init time : " + TimeToString(now, TIME_DATE|TIME_MINUTES));

   

    

//---

   return(0);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

//---

  if (TimeCurrent() < allowed_until) 

    {        

    }

   else Print("EA expired."); 

  } 
Rodrigo Malacarne
Moderator
9947
Rodrigo Malacarne 2015.09.15 05:11  
Suy Kok Yik:

Dear Sir,

I need somebody to correct the follow code:

Hello Suy Kok Yik,

Please take a look at the Freelance section of the website.

Regards,
Malacarne 

web11
268
web11 2015.09.16 11:53  
code is ok. actually what u want
Suy Kok Yik
246
Suy Kok Yik 2015.10.11 10:11  
web11:
code is ok. actually what u want

But how come the EA still allowed to attached to different broker and different account ?

Suy Kok Yik
246
Suy Kok Yik 2015.10.11 10:42  
Suy Kok Yik:

But how come the EA still allowed to attached to different broker and different account ?

Can you help me to correct my EA ? I will send you my EA and can you help me to add in this lock into my EA?
Marco vd Heijden
Moderator
4732
Marco vd Heijden 2015.10.11 10:58  

of course it still allows all brokers because you only filter on time.

void OnTick()

  {

//---

  if (TimeCurrent() < allowed_until) 

    {        

    }

   else Print("EA expired."); 

  if you want more filter you have to code them in as well.

Suy Kok Yik
246
Suy Kok Yik 2015.10.11 13:10  
Marco vd Heijden:

of course it still allows all brokers because you only filter on time.

  if you want more filter you have to code them in as well.

Sir
Can i send u my EA and you help me to code  in the allow  period  , broker and limited by account  no?

Regards  
To add comments, please log in or register