Help secure my ea with account number

 

Hello i need help,

I have start the code of my ea, but i have one error "int start" already use. I see who i have 2 line int start, but by which I must replace the 2nd (i am novice)

can one user send to me the correct syntaxe ? thank you 



int ccc = 123;


int start ()


{


if (AccountNumber ()! = ccc) return (0);


...........................


}



//=============================================================================================================


int start()

  {

   string batas="2020.05.01 00:00"; 

   int tt=StrToTime(batas);

   if(TimeCurrent()>tt)

     {

      Alert(" Licence Ended ");

      return(0);

}

 
jimmytonyy:

Hello i need help,

I have start the code of my ea, but i have one error "int start" already use. I see who i have 2 line int start, but by which I must replace the 2nd (i am novice)

can one user send to me the correct syntaxe ? thank you 



int ccc = 123;


int start ()


{


if (AccountNumber ()! = ccc) return (0);


...........................


}



//=============================================================================================================


int start()

  {

   string batas="2020.05.01 00:00"; 

   int tt=StrToTime(batas);

   if(TimeCurrent()>tt)

     {

      Alert(" Licence Ended ");

      return(0);

}

First of all, when you post code use Alt+S function! Secondly it's all wrong coded. To make that kind of licence you are trying to make you need to do as followed;

Code not tested and i assumed you wanted it for MQL4 and not MQL5

int AccountNo1=12345;//Account number to use
datetime ExpiryDate=D'01.05.2020';//When to expire....

//---
int OnInit()
{
if(!IsTesting()
{
if(TimeCurrent()>=ExpiryDate)
     {
      Alert(" Licence Ended ");
      ExpertRemove();   
      return(INIT_FAILED);
     }
}
if(AccountNumber()!=AccountNo1)
     {
      Print("Account number don't match");
      ExpertRemove();
      return(INIT_FAILED);
     }
return(INIT_SUCCEEDED);
}
//---
void OnDeinit(const int reason)
  {
   
  }
//---
void OnTick()
{
//your ea logics here.......
return;
}
 
I tried to act on your advice, but nothing worked.
 
Grokus:
I tried to act on your advice, but nothing worked.

Saying nothing worked is kind of vague...show your code and your attempt to implement it maybe instead of saying it don't work! The code i gave you work fine so i think you have implemented it all wrong

 
or....check this out in code base how it's done https://www.mql5.com/en/code/27428
Expert adviser licence protection template
Expert adviser licence protection template
  • www.mql5.com
You may want to protect your expert adviser project from unauthorized usage if shared by any reason. This guide 'template' will guide you 'how to' use three different types of licensing and of course all three can be disabled/enabled. I've seen a lot of community members struggling with this and how to do it and what to use....and remember this...
 
Kenneth Parling:
or....check this out in code base how it's done  https://www.mql5.com/en/code/27428

Great job with the template Kenneth.


Thanks

 
Michael Yu:

Great job with the template Kenneth.


Thanks

Thank you!

Reason: