Need help with adding Alerts that not flood me!, please help!

 

i have a code that showing me a symbol alert with colors, as i'm trying to add an alerts code to it, its just flooding me with alert!

please can someone help me with that please and add alerts without flooding?.. big thanks for the helpers!

 
Karish:

i have a code that showing me a symbol alert with colors, as i'm trying to add an alerts code to it, its just flooding me with alert!

please can someone help me with that please and add alerts without flooding?.. big thanks for the helpers!

Either just Alert once per bar or remember when you last alerted and check when that was before Altering the next time.
 
can you help me and add the alerts on and reupload it please?, big thanks
 
Karish:
can you help me and add the alerts on and reupload it please?, big thanks
Yes I can, but I won't, I'm not here to code for you . . . if you want someone to write you code for you then go here: MT4 & MT5 code written for other people
 
//+------------------------------------------------------------------+
//| Function..: Msg                                                  |
//| Parameters: sMessage   - Prompt/Info/Error message.              |
//|             bCanRepeat - Message may be displayed again if it is |
//|                          the same as the previous one.           |
//| Purpose...: Alert messages.                                      |
//| Returns...: sMessage + 0                                         |
//|             The return int value of 0 allows the calling function|
//|             to return 0=false, 1=true or -1=failed ticket        |
//|             eg. return(Msg("OrderSelect error")-1);              |
//| Samples...: Msg("Warning");       // "Warning"                   |
//+------------------------------------------------------------------+
int Msg(string sMessage="", bool bCanRepeat=false) {
   static string sPreviousMessage="";

   if (bCanRepeat || (sPreviousMessage != sMessage)) {
      sPreviousMessage=sMessage;
      Alert(sMessage);
   }
   return(0);
}
 
sxTed:


thanks sxTed but still the same problem flooding problem...

can you please add it for me i beg you!, i was is very important to me!, and i tried all my best to have it done, still its just flooding me...

if you can please help me mate god bless you

here is the code

thanks you.

 
Karish: can you please add it for me i beg you!, i was is very important to me!, and i tried all my best to have it done, still its just flooding me...
  1. You can stop your begging. It isn't important to us. You haven't shown that you have done anything. Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. Don't count up. Don't signal on old bars. Don't signal on current forming bar.
 

Alright do you think thats good?,.. cuz its now aint alerting me untill now.., but its stoped flooding..

a little help please..: thank you guys,

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 3
#property indicator_color1 White
#property indicator_color2 GreenYellow
#property indicator_color3 Red

#property indicator_width1 2
#property indicator_width2 1
#property indicator_width3 1

#property indicator_levelcolor DimGray
#property indicator_level1 70
#property indicator_level2 30
//---- input parameters
extern int       PeriodRSI=50;
extern int SoundAlert = true; ////////////////// NEED TO FIX! <<
extern string   none       = "///////////////////////";
extern string uniqueID         = "On chart signals settings:";
extern bool   showOnChartText  = true;
extern string textForUpPeak    = "S";
extern color  colorForUpPeak   = Red;
extern string textForDownPeak  = "B";
extern color  colorForDownPeak = GreenYellow;
extern int fontsize = 10;
extern bool   SellTrigger = false;
extern bool   BuyTrigger = false;
extern int Arik_Was_Here = true;
//---- buffers
double RSILine1[];
double SupLevel2[];
double ResLevel3[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,RSILine1);
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,251);
   SetIndexBuffer(1,SupLevel2);
   SetIndexEmptyValue(1,0.0);
   SetIndexDrawBegin(1,1);
   SetIndexLabel(1,"SupLevel");
   
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,251);
   SetIndexBuffer(2,ResLevel3);
   SetIndexEmptyValue(2,0.0);
   SetIndexDrawBegin(2,1);
   SetIndexLabel(2,"ResLevel");
   
   
   string short_name="RSI";
   IndicatorShortName(short_name);



//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   string lookFor = uniqueID+":";
   for (int i=ObjectsTotal(); i>=0; i--)
   {
      string name = ObjectName(i); if (StringFind(name,lookFor)==0) ObjectDelete(name);
   }
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int    counted_bars=IndicatorCounted();
   double rsi1,rsi2,rsi3,rsi4;
   
   //Draw RSI & Plot the Peak/Bottom RSI
   if (counted_bars<0) return(-1); 
    
   if (counted_bars>0) counted_bars--; 
    
   limit=Bars-counted_bars;
   
   for (int i=0; i<limit; i++) 
      { 
         RSILine1[i]=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i);
   
         rsi1=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i+1);
         rsi2=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i+2);
         rsi3=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i+3);
         rsi4=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i+4);
         
         double atr = iATR(NULL,0,10,i);
         ObjectDelete(uniqueID+":"+Time[i+2]);
   
         if  ((rsi1<rsi2 && rsi2>rsi3) || (rsi1<rsi2 && rsi2==rsi3 && rsi3>rsi4))
            {                    
               ResLevel3[i+2]=rsi2; //Menandai Level Resistance
               SetComment(High[i+2]+atr,Time[i+2],textForUpPeak,colorForUpPeak);
               //
               bool SellTrigger = true;
               if (SoundAlert == true) { Msg(Symbol()+Period()+"Min  -  RSI: Resistance (X) has been created!  [SELL!]"); }
               //
            }
         if  ((rsi1>rsi2 && rsi2<rsi3) || (rsi1>rsi2 && rsi2==rsi3 && rsi3<rsi4)) 
            {  
               SupLevel2[i+2]=rsi2; //Menandai Level Support
               SetComment(Low[i+2]-atr,Time[i+2],textForDownPeak,colorForDownPeak);
               //
               bool BuyTrigger = true;
               if (SoundAlert == true) { Msg(Symbol()+Period()+"Min  -  RSI: Support (X) has been created!  [BUY!]"); }
               //
            }
      }
   return(0);
  }
  
void SetComment(double price, datetime time, string text,color theColor)
{
   if (!showOnChartText) return;
   string name = uniqueID+":"+time;
      ObjectCreate(name,OBJ_TEXT,0,0,0);
         ObjectSet(name,OBJPROP_PRICE1,price);
         ObjectSet(name,OBJPROP_COLOR,theColor);
         ObjectSet(name,OBJPROP_TIME1,time);
         ObjectSetText(name,text,fontsize,"Arial Bold");
}  



int Msg(string sMessage="", bool bCanRepeat=false) {
   static string sPreviousMessage="";
   if (bCanRepeat || (sPreviousMessage != sMessage)) {
      sPreviousMessage=sMessage;
      if(SellTrigger==true) { Alert(sMessage); bool SellTrigger = false; } else { return; }
      if(BuyTrigger==true) { Alert(sMessage); bool BuyTrigger = false; } else { return; }
   }
   return(0);
}


//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
 
Karish:

Alright do you think thats good?,.. cuz its now aint alerting me untill now.., but its stoped flooding..

a little help please..: thank you guys,

Do you know what you actually want it to do other than not "flood" ? and now it's not "flooding" you still aren't happy . . . even though you got the code for free.
 

no.., its just not working.. the alert not alerting me, but the script not showing any errors...,

so.. basically what im trying to do is just add an alert on every signal that the indicator is giving, just to add an alert signal when the signal is popping thats it..,

and when i do add something its just flooding me with alerts every second, and now when i tried to fix it, there is no alerts at all..

please i just need that little help, thank you again.

 

Next time just do a search of your problem. A lot of things have been solved by other people already and you can almost always find a solution before creating a new topic.

The following code will give alert only once per bar. (Search for "alert once" and you might find other solutions also)

And by the way you need to work on the logic of the alert, because this way it may give you both BUY and SELL alerts on the same bar :). No good!

#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 3
#property indicator_color1 White
#property indicator_color2 GreenYellow
#property indicator_color3 Red

#property indicator_width1 2
#property indicator_width2 1
#property indicator_width3 1

#property indicator_levelcolor DimGray
#property indicator_level1 70
#property indicator_level2 30
//---- input parameters
extern int       PeriodRSI=50;
extern int SoundAlert = true; ////////////////// NEED TO FIX! <<
extern string   none       = "///////////////////////";
extern string uniqueID         = "On chart signals settings:";
extern bool   showOnChartText  = true;
extern string textForUpPeak    = "S";
extern color  colorForUpPeak   = Red;
extern string textForDownPeak  = "B";
extern color  colorForDownPeak = GreenYellow;
extern int fontsize = 10;
extern bool   SellTrigger = false;
extern bool   BuyTrigger = false;
extern int Arik_Was_Here = true;

int BarsTotal; 

//---- buffers
double RSILine1[];
double SupLevel2[];
double ResLevel3[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,RSILine1);
   
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,251);
   SetIndexBuffer(1,SupLevel2);
   SetIndexEmptyValue(1,0.0);
   SetIndexDrawBegin(1,1);
   SetIndexLabel(1,"SupLevel");
   
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,251);
   SetIndexBuffer(2,ResLevel3);
   SetIndexEmptyValue(2,0.0);
   SetIndexDrawBegin(2,1);
   SetIndexLabel(2,"ResLevel");
   
   
   string short_name="RSI";
   IndicatorShortName(short_name);



//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   string lookFor = uniqueID+":";
   for (int i=ObjectsTotal(); i>=0; i--)
   {
      string name = ObjectName(i); if (StringFind(name,lookFor)==0) ObjectDelete(name);
   }
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int    counted_bars=IndicatorCounted();
   double rsi1,rsi2,rsi3,rsi4;
   
   //Draw RSI & Plot the Peak/Bottom RSI
   if (counted_bars<0) return(-1); 
    
   if (counted_bars>0) counted_bars--; 
    
   limit=Bars-counted_bars;
   
   for (int i=0; i<limit; i++) 
      { 
         RSILine1[i]=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i);
   
         rsi1=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i+1);
         rsi2=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i+2);
         rsi3=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i+3);
         rsi4=iRSI(NULL,0,PeriodRSI,PRICE_CLOSE,i+4);
         
         double atr = iATR(NULL,0,10,i);
         ObjectDelete(uniqueID+":"+Time[i+2]);
   
         if  ((rsi1<rsi2 && rsi2>rsi3) || (rsi1<rsi2 && rsi2==rsi3 && rsi3>rsi4))
            {                    
               ResLevel3[i+2]=rsi2; //Menandai Level Resistance
               SetComment(High[i+2]+atr,Time[i+2],textForUpPeak,colorForUpPeak);

               if (SoundAlert == true) { 
                  if (Bars>BarsTotal || BarsTotal==0){
                  Alert(Symbol()+Period()+"Min  -  RSI: Resistance (X) has been created!  [SELL!]"); 
                  BarsTotal=Bars;}
               }
            }
         if  ((rsi1>rsi2 && rsi2<rsi3) || (rsi1>rsi2 && rsi2==rsi3 && rsi3<rsi4)) 
            {  
               SupLevel2[i+2]=rsi2; //Menandai Level Support
               SetComment(Low[i+2]-atr,Time[i+2],textForDownPeak,colorForDownPeak);

               if (SoundAlert == true) { 
                  if (Bars>BarsTotal || BarsTotal==0) {
                  Alert(Symbol()+Period()+"Min  -  RSI: Support (X) has been created!  [BUY!]");
                  BarsTotal=Bars; }
               }
            }
      }
   return(0);
  }
  
void SetComment(double price, datetime time, string text,color theColor)
{
   if (!showOnChartText) return;
   string name = uniqueID+":"+time;
      ObjectCreate(name,OBJ_TEXT,0,0,0);
         ObjectSet(name,OBJPROP_PRICE1,price);
         ObjectSet(name,OBJPROP_COLOR,theColor);
         ObjectSet(name,OBJPROP_TIME1,time);
         ObjectSetText(name,text,fontsize,"Arial Bold");
}  

//+------------------------------------------------------------------+
Reason: