How to Run EA after each xx Seconds - page 2

 
springyard:


how about this :-

And if the next tick doesn't arrive for another 2 minutes ? then what ?
 
springyard:


how about this :-


Nice Dude.. Good one.. it's just a basic thing but good to use.. (sorry for that about I don't know even basic's)
 

Finally Simple and effective solution is;

int start()
{
  int time1=1;
  while (time1>0)
  {
  Alert("test");
  Sleep(30000);
  }
}
 
d.saravana21:

Finally Simple and effective solution is;


int start()
{
  int time1=1;
  while (time1>0)
  {
  Alert("test  Bidprice  ",Bid,"    and Askprice  ",Ask);
  Sleep(30000);
  }
}
 
d.saravana21:

Finally Simple and effective solution is;


int start()
{
  int time1=1;
  while (time1>0)
  {
  Alert("test");
  Sleep(30000);
  }
}
That is an endless loop as time1 will always be > 0 and will not make the program run every 30 seconds, just alert and do nothing else.
 
GumRai:

That is an endless loop as time1 will always be > 0 and will not make the program run every 30 seconds, just alert and do nothing else.

Sure.. it's endless one. but we can stop this by adding other script. (like showing comment("all done"))

and it's sample one. not the full program. see what i'm asked. i asked any sample prg.

 
If you sleep, you must refresh :)
 
d.saravana21:

Sure.. it's endless one. but we can stop this by adding other script. (like showing comment("all done"))

and it's sample one. not the full program. see what i'm asked. i asked any sample prg.

No, you asked . . .

Kindly Give me Ideas to do that in proper way.

. . . there is no proper way, they are all a compromise/bodge.

 

What you are wanting to do is to perform a task every so many seconds... If someone asked you to ring a bell every 5 seconds all you would have to do is watch your stopwatch and ring it every 5 seconds. But the point is... you would have to be able to see your watch at all times.

You have to realize that your EA does 'not have it's eyes open' all the time. Obviously you can only see your watch when you are awake and have your eyes open looking at the watch. Ea's have a VERY short attention span. When a tick (price change) comes in. It wakes up the slumbering EA and it runs all the code in the start().. then immediately goes back to sleep. If it happens to be the last tick on Friday .. it will sleep until the markets open in sydney... It is not aware of any time passing.. when the first tick comes in... it wakes up and looks at the watch.

The only way to get your EA to do something every so many seconds is for the ea to be running constantly and be conscious of passing time.. and alas that is not the way they are wired. They are totally dependent on ticks coming in to keep them awake... So to ask your EA to do something every 10 seconds .. when it only gets has a tick coming in every 15 seconds to wake it up.... well I think you see the problem at hand. ....Yes you can put a 'Sleep' line in there to make it wait so many milliseconds to do something .. but alas.. it only reads that line when the ea is awoken by a tick.... It wakes up .. it does it's stuff.. it waits x millliseconds... start() finishes running and then it's asleep again...zzzzzzzzzzzzzzz

I have some videos on youtube you can watch if you like. I think that the one that shows how and when experts, indicators and scripts run is in 'Mql4 lesson 5' .. just go do a search.. I'm sure you'll find it... Hope this helps.. PipPip... Jimdandy

 
d.saravana21:

Nice Dude.. Good one.. it's just a basic thing but good to use.. (sorry for that about I don't know even basic's)

glad to help :)
Reason: