//+------------------------------------------------------------------+
//|                                                                  |
//|                                                          dfff    |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_color1 Aqua
#property indicator_color2 DeepPink

#property indicator_buffers 2
//---- input parameters
//---- buffers
double UpBuffer[];
double DnBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

  // IndicatorBuffers(2);
   SetIndexStyle(0,DRAW_ARROW,EMPTY,1);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,1);
  
   SetIndexBuffer(0,UpBuffer);
   SetIndexBuffer(1,DnBuffer);
  
   SetIndexArrow(0,233);
   SetIndexArrow(1,234);

   SetIndexLabel(0,"Up Signal");
   SetIndexLabel(1,"Down Signal");

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) counted_bars=0;
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
  //define vars you need multiple times once before the main loop
   int k;
   double MA7_5,MA7_5_1,MA22_5,MA22_5_1;
   
   for(int i=1; i<limit; i++){
      double MA7_30    = iMA(Symbol(),0,7,0,1,0,i);
      double MA7_30_1  = iMA(Symbol(),0,7,0,1,0,i+1);
      double MA22_30   = iMA(Symbol(),0,22,0,1,0,i);
      double MA22_30_1 = iMA(Symbol(),0,22,0,1,0,i+1); 
      
     if(MA7_30 > MA22_30 && MA7_30_1 <= MA22_30_1){   
     for(k=i ;k<i+100;k++) {
        MA7_5    = iMA(Symbol(),5,7,0,1,0,k);
        MA7_5_1  = iMA(Symbol(),5,7,0,1,0,k+1);
        MA22_5   = iMA(Symbol(),5,22,0,1,0,k);
        MA22_5_1 = iMA(Symbol(),5,22,0,1,0,k+1); 
      
    if(MA7_5 > MA22_5 && MA7_5_1 <= MA22_5_1) {     
               
        UpBuffer[i] = iLow(Symbol(),0,i)-(10*Point);
        DnBuffer[i] = EMPTY_VALUE;
        }
       }
     }
       
       else if(MA7_30 < MA22_30 && MA7_30_1 >= MA22_30_1){
       for(k=i;k<i+100;k++){
       MA7_5    = iMA(Symbol(),5,7,0,1,0,k);
       MA7_5_1  = iMA(Symbol(),5,7,0,1,0,k+1);
       MA22_5   = iMA(Symbol(),5,22,0,1,0,k);
       MA22_5_1 = iMA(Symbol(),5,22,0,1,0,k+1); 
      
      if(MA7_5 < MA22_5 && MA7_5_1 >= MA22_5_1){
       
        UpBuffer[i] = EMPTY_VALUE;
        DnBuffer[i] = iHigh(Symbol(),0,i)+(10*Point);
       }
      }
     }
      else{
        DnBuffer[i] = EMPTY_VALUE;
        UpBuffer[i] = EMPTY_VALUE;
       }
  }   

//----
   return(0);
  }