Why do my indicators send emails frequently

 

Indicator Code:

//Code Start//

extern int BRARperiod = 26;
double BR[]; 
double AR[]; 
double CrossUp[];
double CrossDown[];
int init() 
       { 
       IndicatorBuffers(4); 
       //SetIndexStyle(0, DRAW_LINE); 
       SetIndexBuffer(0, BR); 
       //SetIndexStyle(1, DRAW_LINE, STYLE_DOT); 
       SetIndexBuffer(1, AR); 
       SetIndexStyle(2, DRAW_ARROW,EMPTY,EMPTY,clrRed);
       SetIndexBuffer(2, CrossUp);
       SetIndexArrow(2, 233);
       SetIndexStyle(3, DRAW_ARROW,EMPTY,EMPTY,clrLightSkyBlue);
       SetIndexBuffer(3, CrossDown);
       SetIndexArrow(3, 234);
       //IndicatorShortName("BRAR(" + BRARperiod + ")"); 
       
       return (0); 
       } 

int deinit() 
         { 
         return (0); 
         } 
         
int start() 
         { 
         double HCY; 
         double CYL; 
         double HO; 
         double OL; 
         int signal;
         signal = 0;
         int counted_bars = IndicatorCounted();        
         if (counted_bars < 0) 
         return (-1); 
         if (counted_bars > 0) 
         counted_bars--; 
         int i = Bars - BRARperiod + 1; 
         if (counted_bars > BRARperiod - 1) 
         i = Bars - counted_bars - 1; 
         while (i >= 0) 
              {
              CrossUp[i]= EMPTY; 
              CrossDown[i]= EMPTY; 
              HCY = 0; 
              CYL = 0; 
              HO = 0; 
              OL = 0; 
              for (int k = i + BRARperiod - 1; k >= i; k--) 
              { 
                HCY += MathMax(0, High[k] - (Close[k + 1])); 
                CYL += MathMax(0, Close[k + 1] - Low[k]); 
                HO += High[k] - Open[k]; 
                OL += Open[k] - Low[k]; 
              } 
              BR[i] = 100.0 * HCY / CYL;
              AR[i] = 100.0 * HO / OL; 
                if((BR[i]<=30) && (AR[i]<=30)&& (BR[i+1]<=30) && (AR[i+1]<=30)&& (BR[i]>BR[i+1] && BR[i+2]>BR[i+1] && AR[i]>AR[i+1] && AR[i+2]>AR[i+1])){CrossUp[i]=Low[i]*0.9995;}                
                i--;
              signal = 0; 
              }
   
             if(CrossUp[1]>0 && signal == 0)
              {  SendMail(Symbol() + "signal trader email" ,Symbol()+" planpo "+TimeToStr(TimeCurrent(),TIME_SECONDS));
                 signal = 1;
                 printf("send mail");
                }              
              return (0); 

              }

//Code End//


How to fix it? Help me.

  
 

Forum on trading, automated trading systems and testing trading strategies

When you post code please use the CODE button (Alt-S)!

Use the CODE button


原因: