Protecting EA from unauthorized use

 

I developed and EA and wanted to protect it from unauthorized use , so i used time limit from an article mentioned here.

#property copyright "Copyright © 2009, etc"
#property link      "http://etc.com.ua"

int start()
{datetime LastAllowedDate = D'2009.09.11 23:59:00'; 

  if (TimeCurrent() >= LastAllowedDate) 
  {
    Print("Demo period has expired " + TimeToStr(LastAllowedDate,TIME_DATE|TIME_SECONDS));
    return(1);
  }
  
  Print("You can work until "+ TimeToStr(LastAllowedDate,TIME_DATE|TIME_SECONDS));
}

and the ea is still working normally although it is expired

 
nidalzd:

I developed and EA and wanted to protect it from unauthorized use , so i used time limit from an article mentioned here.

and the ea is still working normally although it is expired

How would that stop the EA though, shouldn't it be in the OnTick() event?
 
nidalzd: I developed and EA and wanted to protect it from unauthorized use , so i used time limit from an article mentioned here. and the ea is still working normally although it is expired
#property strict

datetime LastAllowedDate = D'2009.09.11 23:59:00'; 

void OnTick() {
   if( TimeCurrent() <= LastAllowedDate ) {
      Print( "You can work until ",      TimeToString( LastAllowedDate ) );
    } else {
      Print( "Demo period has expired ", TimeToString( LastAllowedDate ) );
      ExpertRemove();
    };
};

ExpertRemove

Stops Expert Advisor and unloads it from the chart

Common Functions

ExpertRemove - Common Functions - MQL4 Reference
ExpertRemove - Common Functions - MQL4 Reference
  • docs.mql4.com
ExpertRemove - Common Functions - MQL4 Reference