static datetime alert_bar_time=0; double Kijun_H4_2=iIchimoku(Symbol(),240,9,26,52,MODE_KIJUNSEN,2), Kijun_H4_1=iIchimoku(Symbol(),240,9,26,52,MODE_KIJUNSEN,1); if(alert_bar_time!=iTime(Symbol(),240,0)) { alert_bar_time=iTime(Symbol(),240,0); if(iClose(Symbol(),240,2)<Kijun_H4_2 && iClose(Symbol(),240,1)>Kijun_H4_1) { Alert("Break Up on "+Symbol()); } else if(iClose(Symbol(),240,2)>Kijun_H4_2 && iClose(Symbol(),240,1)<Kijun_H4_1) { Alert("Break Down on "+Symbol()); } }
.
.
You are alerting on a condition. Remembering the alert time is one way. | if(iClose(Symbol(), 240, 2) < Kijun_H4_2 && iClose(Symbol(), 240, 1) > Kijun_H4_1){ Alert("Break Up on " + Symbol()); } |
The other is look for a change in the condition. | static bool is_up=false; bool was_up = is_up; is_up = iClose(Symbol(), 240, 2) < Kijun_H4_2 && iClose(Symbol(), 240, 1) > Kijun_H4_1; if(is_up && !was_up){ Alert("Break Up on " + Symbol()); } |
Thanks Keith Watford for the reply on Walidabou difficulties, however, all global variables are static by default, so, there would be no need including the static keyword in defining the datatime variable except inside a function where variables are dynamic (not static) by default.
Walidabou's code is inside the function OnTick() so the static datetime variable is necessary..
datetime curTime = 0; datetime prevTime = iTime(_Symbol, _Period, 0); if (curTime != prevTime) { Alert("do something "); curTime = prevTime; }
Use the code button (Alt + S) when posting code.
Seems to me that you have curTime and prevTime back to front.
Your datetime variable curTime needs to be static as it will not be remembered next execution.
Why are you replying to a 4 year old thread ?
Hi EveryBody ,, i have a a problem with my simple expert advisor which gives Alert with some conditions as shown in code below ,, but the Alert works when every tick ,, how can i stop it ??
Thanks in advance
Well, I am using this for an indicator and in the section
for (i=limit; i>=0;i--)
I use :
if (i<1) Alert("do something ");
If I do not, every time I modify/compile the indicator or open it, it sends so many notifications. Hope this comment may help.
if (i<1) Alert("do something ");
That condition will be true each and every tick.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi EveryBody ,, i have a a problem with my simple expert advisor which gives Alert with some conditions as shown in code below ,, but the Alert works when every tick ,, how can i stop it ??
Thanks in advance