How to set expiry date on EA/Indicator for licensing and protection?

As a way of licensing/protection,I need to disable my indicator/ea after an expiry date is reached.
Does anyone have a script ready to put the usage time? What does the mql5 site show does not work on my indicator, does anyone have one?

for days, hours, minutes

you mean an a script to show how long your MetaTrader has been open?

No, time for indicator to stop working

example: you want a demonstration of my indicator, so I offer one with a validity of 2 days

When your Indicator is opened for the first time you need to record the date and store it somewhere. It can be stored in a file. Next, you should regularly compare the current date with the stored date to see if the difference is more than, for example, two days. If it is, then stop the indicator and show a expiry message to the user. You can place the code that checks for the expiry in OnCalculate or onTimer. So in short, here are the steps

  1. check if a file setting exists, if not create one and store the current date as start_trial_date
  2. read the date from the file
  3. compare the date with current date and if the difference is more than 2 days (or any number of days), disable the EA.

There are other ways to secure an EA/Indicator:

  • Password protection : The first most used solution for a protection of computer software is password or license key protection. During first run after installation the user is queried with a dialog box to insert a password tied with a software copy (like the Microsoft Windows or Microsoft Office serial key) and if the entered password matches the user is allowed to use a single registered copy of a software. We can use an input variable or a direct textbox to enter the code
  • Key generator: Key generators are a mechanism that allows to use a set of passwords based on predefined rules. I will give an overview by providing a stub for a keygenerator below. In the example presented below the key must consist of three numbers separated by two hyphens. Therefore the allowed format for a password is XXXXX-XXXXX-XXXXX.
  • Single Account LicenseSince the Account number of the terminal of any given broker is unique this can be used to allow usage of the EA on one or a set of account numbers. In such case it is enough to use AccountInfoString(ACCOUNT_COMPANY) and AccountInfoInteger(ACCOUNT_LOGIN) methods to fetch the account data and compare it against precompiled allowed values:
  • Time-limit Protection: This is what you want. Time-limit protection is useful when the license is granted on temporary basis, for example using trial version of the software or when the license is granted on monthly or yearly basis. Since this is obvious that this can be applied for Expert Advisors and Indicators. First idea is to check server time and based on that let the user use the Indicator or Expert Advisor within given period of time. After it expires the licensor is able to partially or totally disable its functionality to the licensee.
  • Remote licenses :Wouldn’t it be good to have a total control wheter to disable the license or extend the trial period on per user basis? This can simply be done using MQL5-RPC call that would send a query with the account name and receive the value whether to run the script in trial mode or disable it.

For more information see this article:

Maybe this video can help?