Time gap between alerts?

 

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)
{
Alert
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

 
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
 
static datetime TimeStamp;

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

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

Hi, Thank you it worked!

 
Somsri Sarkar: Hi, Thank you it worked!
  1. Of course it worked. But you learned nothing. You should have been able to substitute TimeCurrent for iTime yourself.
  2. 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.)
 
whroeder1:
  1. Of course it worked. But you learned nothing. You should have been able to substitute TimeCurrent for iTime yourself.
  2. 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.

 
whroeder1:
  1. Of course it worked. But you learned nothing. You should have been able to substitute TimeCurrent for iTime yourself.
  2. 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?

 
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.

 

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. 

 
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.
 
Hey kids, may I suggest you to stop this useless (sic) discussion.
Reason: