How to fix this error

To add comments, please log in or register
SatyamGanju
98
SatyamGanju  
datetime allowed_until = D'2012.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."); 
  }
Files:
error.PNG 102 kb
Kourosh Davallou
64093
Kourosh Davallou  
SatyamGanju:
Please show all the program so that it can be fixed
Keith Watford
Moderator
21754
Keith Watford  
Remove the additional OnInit() and OnDeinit() functions.
SatyamGanju
98
SatyamGanju  
which functions to use instead ? sorry im new to coding , can you rewrite the source code using other functions than OnInit() and OnDeinit() functions.?
Keith Watford
Moderator
21754
Keith Watford  
SatyamGanju:
which functions to use instead ? sorry im new to coding , can you rewrite the source code using other functions than OnInit() and OnDeinit() functions.?
Keith Watford:
Remove the additional OnInit() and OnDeinit() functions.

You have duplicated the functions.

Show your code if you need more help.

GrumpyDuckMan
882
GrumpyDuckMan  

 Really ontick();

  if (TimeCurrent() < allowed_until) 
    {        
    }

what is it going to do now?

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);
  }

Note the date set:

datetime allowed_until = D'2012.02.11 00:00'; 

Also password I am sure is meant to be a string, unless you a file or other means.

int password_status = -1;
SatyamGanju
98
SatyamGanju  
Keith Watford:

You have duplicated the functions.

Show your code if you need more help.


Files:
PivotsX.mq4 41 kb
SatyamGanju
98
SatyamGanju  

i have uploaded mq4 file .. pls take a look

im trying to make it time bound indicator and if possible password protected also , i was trying to copy code from this source but im facing errors in both method

https://www.mql5.com/en/articles/359

Pls Help , It would be highly appreciated ;-)

Securing MQL5 code: Password Protection, Key Generators, Time-limits, Remote Licenses and Advanced EA License Key Encryption Techniques
Securing MQL5 code: Password Protection, Key Generators, Time-limits, Remote Licenses and Advanced EA License Key Encryption Techniques
  • www.mql5.com
Most developers need to have their code secured. This article will present a few different ways to protect MQL5 software. All examples in the article will refer to Expert Advisors but the same rules can be applied to Scripts and Indicators. The article starts with simple password protection and follows with key generators, licensing a given...
SatyamGanju
98
SatyamGanju  
GrumpyDuckMan:

 Really ontick();

what is it going to do now?

Note the date set:

Also password I am sure is meant to be a string, unless you a file or other means.

thanks for your reply but im unable to understand what you wishes to tell ... anyways i have upload mq4 file and a link from where im trying to copy code to protect my indicator by adding time bound and password . pls take a look ;-)

Keith Watford
Moderator
21754
Keith Watford  
Your PivotsX file compiles with no errors
SatyamGanju
98
SatyamGanju  
Yes  I know that it compiles with no error... But when I add above mentioned code to make my indicator time bound it shows the error which is mentioned above.. pls check everything & thanks a lot for helping
12
To add comments, please log in or register