//+------------------------------------------------------------------+
//|                                          |
//|                         |
//+------------------------------------------------------------------+

/*
  +------------------------------------------------------------------+
  
  +------------------------------------------------------------------+
*/   

#property indicator_minimum 0.0
#property indicator_maximum 1.5

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_width1 3
#property indicator_color2 Red
#property indicator_width2 3
//----
IndicatorShortName ("PSAR Helper 15M");
IndicatorDigits (0);
double CrossUp[];
double CrossDown[];
//int Mode = 1;
//extern int TimeFrame = 0;



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators



   SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, 4);
   SetIndexBuffer(0, CrossUp);
   SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, 4);
   SetIndexBuffer(1, CrossDown);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int limit, i, counter;
   double MA_1M_Current, MA_1M_Previous, MA_5M_Current,MA_5M_Previous;   
    double MA_Current, MA_Previous;
         
         

      
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;
   
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      for (counter=i ;counter<=i+9;counter++)
      


     
      if (
          iClose(NULL,0,i) > iSAR(NULL, PERIOD_M15,0.04,0.05, i) 

            ) 
            {
         CrossUp[i] = 1;
      }
      else if ( iClose(NULL,0,i) < iSAR(NULL, PERIOD_M15,0.04,0.05, i) 
           
             ) 
            {
         CrossDown[i] = 1;
      }
   }
   return(0);
}

