Expiry date in EA

Gordon Gekko  
45weeks:
How I can implement a validation of EA based on a date, if it is greater than that date show a message "the EA has expired..."?

Hi, maybe like this:

datetime expiry=D'2009.05.03 00:00';

if(TimeCurrent()>expiry)
   {
   Alert("The EA has expired...");
   }
Cheers
[Deleted]  

Thank, I might add that code in any part?

[Deleted]  
45weeks:

Thank, I might add that code in any part?


You will need to either:

a) put it in the init() function and cause it to set a bool flag which you then check in the start() function and continue or return appropriately

b) put it in the start() function and continue or return appropriately

[Deleted]  

I put that code in int start() and works, constantly I see the alert, as I can stop the EA after the first alert?


Thank you

[Deleted]  
45weeks:

I put that code in int start() and works, constantly I see the alert, as I can stop the EA after the first alert?


Thank you

Is that a question or a statement?

[Deleted]  

Is a question...


That is my code:


datetime expiry=D'2009.05.03 00:00';


if(TimeCurrent()>expiry)
{
Alert("The EA has expired...");
YesStop = true;

}


----


It's correct?

Gordon Gekko  
45weeks:

Is a question...


That is my code:


...
int start()
  {
   
   datetime expiry=D'2009.05.03 00:00';
   bool YesStop = false;

   if(TimeCurrent()>expiry)
   {
   Alert("The EA has expired...");
   bool YesStop = true;
   }

   if(YesStop != true)
   {
   
      // ... your code

   }

   return(0);
  }
//+------------------------------------------------------------------+

You have to modify expiry date (today is 09.05.05).

Cheers

[Deleted]  
45weeks:

Is a question...


That is my code:


datetime expiry=D'2009.05.03 00:00';


if(TimeCurrent()>expiry)
{
Alert("The EA has expired...");
YesStop = true;

}


----


It's correct?

Ok. Let's check if my understanding is correct. You wish to only have one alert when the expiry date is exceeded, rather than an alert with each tick (which I incidentally prefer).

To do that, simply set a bool variable bExpiryAlertDelivered to false in the init() function. Then in the start() function, only deliver the alert if this variable is false and the date has expired. Once you've delivered the alert, set it to true. Job done.

init()

 {

  datetime expiry=D'2009.05.03 00:00';

  bExpiryAlertDelivered = false;

 }

start()

 {

  if ((TimeCurrent()>expiry)

   {

    if (bExpiryAlertDelivered == false))
     {
      Alert("The EA has expired...");
      bExpiryAlertDelivered = true;

     } 

   YesStop = true;

  }

 }

JC  
45weeks:
How I can implement a validation of EA based on a date, if it is greater than that date show a message "the EA has expired..."?

I'll throw in one thing which no-one else has mentioned yet: it's very easy to decompile an ex4 file back to mq4. And then it's very easy to identify a block of code which handles expiry, to remove it, and then to recompile the mq4 giving you a version of the code which works fine but has no expiry.

[Deleted]  
jjc wrote >>

I'll throw in one thing which no-one else has mentioned yet: it's very easy to decompile an ex4 file back to mq4. And then it's very easy to identify a block of code which handles expiry, to remove it, and then to recompile the mq4 giving you a version of the code which works fine but has no expiry.

how true... even if compiled to m/c code as touted in '5', can reverse engineer.

from what I see of current public code, there is always a dll and/or server involved when running an EA and of course the obligatory infamous key/serNo/jibberish/...

the never ending journey ;)