# Time gap between alerts?

What are the latest MQL5.community news? The Wall section will tell you!
1846
2016.11.29 16:02

Hi

I have following code for adding time gaps between alerts, otherwise tick by tick it creates many continuous alerts.

static datetime TimeStamp;

if(TimeStamp != iTime(Symbol(),PERIOD_M15,0) && some conditions)
{
TimeStamp = iTime(Symbol(),PERIOD_M15,0);
}

But in this code, when then a condition satisfies at 11:14 on next time it show alert at 11:15 because code it used 15 minute time gap.

Is there any way to make time gap of 15 minutes from the current time after the condition satisfies?

Thank you in advance.

Regards

14225
2016.11.29 17:09
 Somsri Sarkar: is there any way to make time gap of 15 minutes from the current time after the condition satisfies? Just do it. TimeCurrent - Date and Time - MQL4 Reference
Moderator
1861
2016.11.29 18:20
static datetime TimeStamp;

if(TimeCurrent() >= TimeStamp && some conditions)
{
TimeStamp = TimeCurrent() + 900; // 15 minutes == 900 seconds
}
1846
2016.11.30 05:26
honest_knave:
static datetime TimeStamp;

if(TimeCurrent() >= TimeStamp && some conditions)
{
TimeStamp = TimeCurrent() + 900; // 15 minutes == 900 seconds
}

Hi, Thank you it worked!

14225
2016.11.30 13:43
 Somsri Sarkar: Hi, Thank you it worked! Of course it worked. But you learned nothing. You should have been able to substitute TimeCurrent for iTime yourself. honest_knave: All you did was help him with his current problem (gave him a fish.) What are you going to do with his next N problems?  If you look in the archives, you will find dozens of comments that my terse comments force the poster to learn, and that they are grateful (teach him to fish.)
Moderator
1861
2016.11.30 14:04
whroeder1:
 Of course it worked. But you learned nothing. You should have been able to substitute TimeCurrent for iTime yourself. honest_knave: All you did was help him with his current problem (gave him a fish.) What are you going to do with his next N problems?

I doubt the OP will be back to ask how they can adjust their alert for 5 minutes (if they are, you will have my apologies).

Therefore the OP most likely has learned something.

I gave them a tool. You gave them instructions on how to make a tool.

Moderator
1861
2016.11.30 14:15
whroeder1:
 Of course it worked. But you learned nothing. You should have been able to substitute TimeCurrent for iTime yourself. honest_knave: All you did was help him with his current problem (gave him a fish.) What are you going to do with his next N problems?  If you look in the archives, you will find dozens of comments that my terse comments force the poster to learn, and that they are grateful (teach him to fish.)

And how many people never posted again, or gave up completely?

14225
2016.11.30 14:58
 honest_knave: And how many people never posted again, or gave up completely? If there are any, they really didn't want to succeed at FX, and were just wasting everyone's time. I try to treat everyone here as an adult. If they act like an adult, I will try to help. If they just want a freebe, or start whining when they don't get it, then they need to grow up. They've wasted our time with their post, so they don't deserve niceness.
Moderator
1861
2016.11.30 15:40

The OP concisely explained their problem, posted an attempt at coding it themselves, and was generally polite and courteous. I don't see the issue.

I think we'll have to respectfully agree to disagree on this one.

14225
2016.11.30 17:32
 honest_knave: The OP concisely explained their problem, posted an attempt at coding it themselves, and was generally polite and courteous. I don't see the issue. Yes he did. I didn't comment on him, I commented on you. I gave you something to think about and three times you had to get the last word in. You are the issue.
Moderator
30243
2016.11.30 17:48
Hey kids, may I suggest you to stop this useless (sic) discussion.
/