Topic: Simple Password protection

Hell,

can someone tell me how i can protect ea with password?

Ich mean: User enter password in ea settings. If it is equal to the password in mql code than the ea Do trades otherwise it will Display a text like password not correct.

I have tried different code snippets on internet i found but they dont work.

Re: Simple Password protection

Actually it is very easy.

Add a text field that to be shown in the Input panel.

static input string Password = "-"; // Password

Add password check in the Expert's initialization function.

int OnInit()
  {
    if (Password != "123456") 
    {
       Print("Wrong password!");
       Comment("Wrong password!");
       return (INIT_FAILED);
    }

... 


https://s9.postimg.org/o5xwksdbj/screenshot_171.png



https://s9.postimg.org/5qdfnku3z/screenshot_172.png

Re: Simple Password protection

this is excellent dear POPOV,
i would also add ExpertRemove();....just to remove the EA if wrong password

    if (Password != "123456")
    {
       Print("Wrong password!");
       Comment("Wrong password!");
       ExpertRemove();
       return (INIT_FAILED);
    }

Re: Simple Password protection

the hard question is , how to make it as a DEMO EA (works only for a specific period of time, then it stops)
how to implement that period in it?

Re: Simple Password protection

You can predefine an expiry date and to request for a valid password after that time.

Another option is to give an EA that will stop after the expiry date. After the trial the user must buy the unlimited copy, which has password protection.

A better option (but it requires more wok) is to make an online licensing service. The expert may ask the service with POST request if this user is valid or not. all licensing logic can be on the server. You may provide a demo password automatically and a real password after purchasing.

The licensing process is hard to be make right. You may search for a ready third party solution.

Re: Simple Password protection

Great. Thank you dear!

Re: Simple Password protection

@popov did you have a code snippet for me to add demo function?