Indicator alert in every 3 seconds
static datetime NextAlert = 0; if(TimeCurrent() >= NextAlert && ... // logic to trigger alert { Alert(....); NextAlert=TimeCurrent()+3; }
or
void OnTimer() { Alert(....); } void OnTick() { if(.... // logic to trigger alert { EventSetTimer(3); OnTimer(); } else { EventKillTimer(); }
#property copyright "tester" #property link "tester@test" #property indicator_chart_window extern double SoundWhenPriceGoesAbove = 0; extern double SoundWhenPriceGoesBelow = 0; int init() if (SoundWhenPriceGoesAbove > 0) { ObjectCreate("SoundWhenPriceGoesAbove", OBJ_HLINE, 0, Time[0], SoundWhenPriceGoesAbove); ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_COLOR, Magenta); ObjectSet("SoundWhenPriceGoesAbove", OBJPROP_WIDTH, 1); } if (SoundWhenPriceGoesBelow > 0) { ObjectCreate("SoundWhenPriceGoesBelow", OBJ_HLINE, 0, Time[0], SoundWhenPriceGoesBelow); ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_STYLE, STYLE_SOLID); ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_COLOR, Magenta); ObjectSet("SoundWhenPriceGoesBelow", OBJPROP_WIDTH, 1); } return(0); } int deinit() { ObjectDelete("SoundWhenPriceGoesAbove"); ObjectDelete("SoundWhenPriceGoesBelow"); return(0); } int start() { if (ObjectGet("SoundWhenPriceGoesAbove", 1) != SoundWhenPriceGoesAbove) SoundWhenPriceGoesAbove = ObjectGet("SoundWhenPriceGoesAbove", 1); if (ObjectGet("SoundWhenPriceGoesBelow", 1) != SoundWhenPriceGoesBelow) SoundWhenPriceGoesBelow = ObjectGet("SoundWhenPriceGoesBelow", 1); if ((Bid > SoundWhenPriceGoesAbove) && (SoundWhenPriceGoesAbove > 0)) { PlaySound("alert.wav"); Sleep(1000); } if ((Bid < SoundWhenPriceGoesBelow) && (SoundWhenPriceGoesBelow > 0)) { PlaySound("alert.wav"); Sleep(1000); } return(0); }
Dear Friends and Traders.. I've doubt in my Price alert indicator. It alerts on every incoming tick.. but i like to get alert on every 3 seconds..
the every incoming tick alert is annoying. Please guide me..