Download MetaTrader 5

Expiry date in EA

To add comments, please log in or register
Have you found an error in our products? Apply to Service Desk!
45weeks
40
45weeks 2009.05.03 20:48 
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..."?
Gordon Gekko
622
Gordon Gekko 2009.05.03 21:21  
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
45weeks
40
45weeks 2009.05.05 21:11  

Thank, I might add that code in any part?

cloudbreaker
1577
cloudbreaker 2009.05.05 21:20  
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

45weeks
40
45weeks 2009.05.05 21:34  

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

cloudbreaker
1577
cloudbreaker 2009.05.05 21:37  
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?

45weeks
40
45weeks 2009.05.05 21:39  

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
622
Gordon Gekko 2009.05.05 22:55  
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

cloudbreaker
1577
cloudbreaker 2009.05.06 11:23  
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
1456
JC 2009.05.06 11:27  
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.

fbj
1047
fbj 2009.05.06 12:16  
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 ;)

12
To add comments, please log in or register