Hi @Enivid Could you please elaborate more on this?. I could not understand.You need to set up a timer with EventSetTimer() and then use OnTimer() event to check if alert condition is fulfillied, do the alerts, and advance alert counter (to stop doing alerts after it reaches 100).
How to add that in this code
MQL4:
#property copyright "" #property link "" #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"); } if ((Bid < SoundWhenPriceGoesBelow) && (SoundWhenPriceGoesBelow > 0)) { PlaySound("alert.wav"); } return(0); }