Not send alert when open metatrader for the past signal - page 2

 
Yohana Parmi:


Hi, Aghaali

Actually, I thought your main problem has been fixed ^̮^

And the second step is how to give new value to your variable before next checking at if()

and also you can find many codes that you need here:

https://www.mql5.com/en/code

Thanks so much

i use your code as

int start()
  {
   if (bar==Time[0]) return(0);
   cb=IndicatorCounted();
   int x;
   if(Bars<=100) return(0);
   if (cb<0) return(-1);
   if (cb>0) cb--;
   x=Bars-cb;
   for(int i=0; i<x; i++)
   {
    double r1 = iRSI(NULL,0,rsiperiod,PRICE_CLOSE,i);
    double r2 = iRSI(NULL,0,rsiperiod,PRICE_CLOSE,i+1);
     if (r1>30 && r2<30)
      buffy1[i] = Low[i+1]-15*Point;
      if(lastcandle!=Time[1]){
      if (EnableSoundAlert ){
      SendNotification(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " "+Period());
           
            Alert(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " "+Period());
          
            }
            if (EnableMailAlert) {
               SendMail(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " " +Period(),TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " " +Period());
              
            }
            lastcandle=Time[1];
            }
     bar=Time[0]; 
     if (r1<70 && r2>70)
      buffy2[i] = High[i+1]+15*Point;
      if(lastcandle!=Time[1]){
      if (EnableSoundAlert){
      SendNotification(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI SELL " + Symbol() + " "+Period() );
           
           
           Alert(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI SELL " + Symbol() + " " +Period());
          
            }
            if (EnableMailAlert&&lastcandle!=Time[1]) {
               SendMail(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI SELL " + Symbol() + " " +Period(),TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " " +Period() );
            
            }
            lastcandle=Time[1];
            }
     bar=Time[0]; 
   } 

   return(0);
  }

and Keith Watford  code as

int start()
  {
   if (bar==Time[0]) return(0);
   cb=IndicatorCounted();
   int x;
   if(Bars<=100) return(0);
   if (cb<0) return(-1);
   if (cb>0) cb--;
   x=Bars-cb;
   for(int i=0; i<x; i++)
   {
    double r1 = iRSI(NULL,0,rsiperiod,PRICE_CLOSE,i);
    double r2 = iRSI(NULL,0,rsiperiod,PRICE_CLOSE,i+1);
     if (r1>30 && r2<30)
      buffy1[i] = Low[i+1]-15*Point;
      if(Time[i]>alertBarTime && i==0){
      if (EnableSoundAlert){
      SendNotification(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " "+Period());
           
            Alert(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " "+Period());
            
            }
            if (EnableMailAlert&& Time[i]>alertBarTime && i==0) {
               SendMail(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " " +Period(),TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " " +Period());
              
            }
            alertBarTime=Time[i];
            }
     bar=Time[0]; 
     if (r1<70 && r2>70)
      buffy2[i] = High[i+1]+15*Point;
      if(Time[i]>alertBarTime && i==0){
      if (EnableSoundAlert&& Time[i]>alertBarTime && i==0){
      SendNotification(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI SELL " + Symbol() + " "+Period() );
           
            Alert(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI SELL " + Symbol() + " " +Period());
            
            }
            if (EnableMailAlert&& Time[i]>alertBarTime && i==0) {
               SendMail(TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI SELL " + Symbol() + " " +Period(),TimeToStr(Time[0], TIME_DATE|TIME_MINUTES) + " EXTREAM RSI BUY " + Symbol() + " " +Period() );
            
            }
            alertBarTime=Time[i];
            }
     bar=Time[0]; 
   } 

   return(0);
  }

at separate codes , but both of them has this problem that when i run send notification and email for 1 of past signal! is this problem because of my code!

this is like your code and other like Keith Watford code !

Thanks

 
Mohammad Aghaali:

Thanks so much

i use your code as


Thanks


Hi,

int start()
{
  //.....
  //.....
  x=Bars-cb;
  for(int i=0; i<x; i++) //-- are you really sure to process this at every tick ? it seems heavy ¯\_(ツ)_/¯
  {
    


I hope this can help  ͡° ͜ʖ ͡°)

int start()
{
  
   //.........

  //--check once at every new candle
  if(lastcandle!=Time[0])
  {
    for(int i=0; i<x; i++)
    {
      double r1 = iRSI(NULL,0,rsiperiod,PRICE_CLOSE,i);
      double r2 = iRSI(NULL,0,rsiperiod,PRICE_CLOSE,i+1);

      if (r1>30 && r2<30 && i<1) //--only check signal for last bar
      {
         buffy1[i] = Low[i+1]-15*Point;
    
        if (EnableSoundAlert)
        {
             //--do your alert here     
        }
      }//--end condition R1, R2 and last candle
      else
      if (r1>30 && r2<30) 
      {
         buffy1[i] = Low[i+1]-15*Point;
      }
    }//-- end for
    lastcandle=Time[0];
  }//-- end lastcandle
}//--end start


Good luck (¬‿¬)

 

Hi,

I am not a coder,  but modified the indicator for alert,  but the alerts are generated only for current timeframe and as and when i change the timeframe by clicking M1,M5,M15 etc.,  need alerts for all timeframe whenever certain condition is match.

Please advice to save my indicator.

Regards,

HP

Reason: