# dealing with ODD or double numbers

608

Hello freinds,

I want the EA to check an operation every two minutes.

The simple way is to do:

if (   TimeMinute(TimeCurrent()) != 2  && TimeMinute(TimeCurrent()) != 4  && TimeMinute(TimeCurrent()) != 6  && TimeMinute(TimeCurrent()) != 8  &&
TimeMinute(TimeCurrent()) != 10 && TimeMinute(TimeCurrent()) != 12 && TimeMinute(TimeCurrent()) != 14 && TimeMinute(TimeCurrent()) != 16 &&
TimeMinute(TimeCurrent()) != 18 && TimeMinute(TimeCurrent()) != 20 && TimeMinute(TimeCurrent()) != 22 && TimeMinute(TimeCurrent()) != 24 &&
TimeMinute(TimeCurrent()) != 26 && TimeMinute(TimeCurrent()) != 28 && TimeMinute(TimeCurrent()) != 32 && TimeMinute(TimeCurrent()) != 34 &&
TimeMinute(TimeCurrent()) != 36 && TimeMinute(TimeCurrent()) != 38 && TimeMinute(TimeCurrent()) != 40 && TimeMinute(TimeCurrent()) != 42 &&
TimeMinute(TimeCurrent()) != 44 && TimeMinute(TimeCurrent()) != 46 && TimeMinute(TimeCurrent()) != 48 && TimeMinute(TimeCurrent()) != 50 &&
TimeMinute(TimeCurrent()) != 52 && TimeMinute(TimeCurrent()) != 54 && TimeMinute(TimeCurrent()) != 56 && TimeMinute(TimeCurrent()) != 58  )

Can you think about simpler way to do it?

700

something like this:

```#define ODD  1
#define EVEN 0

int PreviousMinute = ODD;

void OnTick() {
int CurrentMinute = TimeMinute(TimeCurrent()) % 2;
if ((PreviousMinute == ODD) && (CurrentMinute == EVEN)) {
// check operation every two minutes
}
PreviousMinute=CurrentMinute;
}```
1399

Use ontimer for a better timer.
15735

crossy: I want the EA to check an operation every two minutes.
1.  Play video Please edit your post. For large amounts of code, attach it.

2. While
`if(TimeMinute(TimeCurrent()) % 2 == 0) ...`
would trigger every even minute. You probably only want one trigger per.
3. What about when there is no ticks during that minute "Free-of-Holes" Charts - MQL4 Articles don't you want to trigger at the next tick?
```static datetime everyTwoMinutes = 0;
datetime now = TimeCurrent();
if(now >= everyTwoMinutes){
everyTwoMinutes = now + 120;              // Every two.
everyTwoMinutes -= everyTwoMinutes % 120; // Top of the minute.
:```

608

WHRoeder:
1.  Play video Please edit your post. For large amounts of code, attach it.

2. Whilewould trigger every even minute. You probably only want one trigger per.
3. What about when there is no ticks during that minute "Free-of-Holes" Charts - MQL4 Articles don't you want to trigger at the next tick?
608

Thanks