How to Run EA after each xx Seconds

 

Hello Programmers.

How can i make my EA running after each xx Second's

Kindly Give me Ideas to do that in proper way.


With Regards

Saravana

 
d.saravana21:

Hello Programmers.

How can i make my EA running after each xx Second's

Kindly Give me Ideas to do that in proper way.

You can but it's not nice and is a bodge, you will have to refresh rates or use MarketInfo() calls . . . IMO there is no proper way.
 

Now a day's in all my post I'm getting just simple reply from Moderator(RaptorUK). Is here no MT4 Programmers?.

Or all had turned as billionaire :P


With Regards

Saravana

 
d.saravana21:

Now a day's in all my post I'm getting just simple reply from Moderator(RaptorUK). Is here no MT4 Programmers?.

Or all had turned as billionaire :P

If you want someone to write your code for you go here: please write my code for me . . .

As I already said . . . there is no proper way, there is in MT5 there is an OnTimer event, but in MT4 EAs are tick driven . . . a new tick causes start() to be called.
 
d.saravana21:

Now a day's in all my post I'm getting just simple reply from Moderator(RaptorUK). Is here no MT4 Programmers?.

Or all had turned as billionaire :P


With Regards

Saravana


You had a simple, but relevant reply from raptorUK.

You could assign the value of TimeCurrent() to a static or Global scope variable and then check that at least xx seconds has passed and if it hasn't then return(). Of course, this will not be exact, so you cannot guarantee that the EA will calculate exactly every xx seconds.

 

d.saravana21:

How can i make my EA running after each xx Second's

Kindly Give me Ideas to do that in proper way.

GumRai:

You could assign the value of TimeCurrent() to a static or Global scope variable and then check that at least xx seconds has passed and if it hasn't then return(). Of course, this will not be exact, so you cannot guarantee that the EA will calculate exactly every xx seconds.

Yes . . . the condition should be run on next tick after xx seconds. So the time between full executions of start() will not be exactly xx seconds, but it will be on the next tick after the expiration of xx seconds.
 

Ok kindly some one give me an example. write this code into work every 30 sec (what ever it working after 30 sec or more sec from that)

int start()
{
  Alert("hello");
}
 
d.saravana21:

Ok kindly some one give me an example. write this code into work every 30 sec (what ever it working after 30 sec or more sec from that)

int start()
{
  Alert("hello");
} 


"hello"

Have you test it ??

how is it avoiding running every tick ...

 
d.saravana21: Ok kindly some one give me an example. write this code into work every 30 sec (what ever it working after 30 sec or more sec from that)
You'll have to learn the basics otherwise the advise provided by these good people wouldn't make sense. I recommend going through the mql4_book or any beginner programming book. That'll help teach you about global variables.
 
d.saravana21:

Ok kindly some one give me an example. write this code into work every 30 sec (what ever it working after 30 sec or more sec from that)


RaptorUK:
If you want someone to write your code for you go here: please write my code for me . . .

 
d.saravana21:

Ok kindly some one give me an example. write this code into work every 30 sec (what ever it working after 30 sec or more sec from that)


how about this :-

int start()
{
  Alert("hello");
sleep(30000);
}
Reason: