//+------------------------------------------------------------------+
//|                                                           25.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
#property indicator_chart_window
#property indicator_buffers 2

#property indicator_color1 DeepSkyBlue      
#property indicator_color2 DeepPink        

extern int Length = 15;

#property indicator_width1 1  
#property indicator_width2 1  

extern int ArrowDistance = 1;
bool WaitForCandleClose = false;
bool ArrowOnTriggerBar = false;


double Up_Arrow_Buffer[];    
double Down_Arrow_Buffer[];  
int ArrowOffset = 0;





//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexBuffer(0, Up_Arrow_Buffer);
   SetIndexArrow(0, 225); 
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexBuffer(1, Down_Arrow_Buffer);
   SetIndexArrow(1, 226); 
   
//----
   return(0);
  }
  
  
  
  
  
  
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
  
  
  
  
  
  
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int i;                           
   int Counted_bars;                
   //--------------------------------------------------------------------   
   Counted_bars=IndicatorCounted();  
   i=Bars-Counted_bars-1;           
   
   for ( i=300; i>=0; i-- ) {
         if (Close[i] > ((High[i] - Low[i])*45/100 + Low[i]) && Open[i] > ((High[i] - Low[i])*45/100 + Low[i]) && Close[i] < iMA(NULL,0,Length,0,MODE_EMA,0,i))
         {
            Up_Arrow_Buffer[i-ArrowOffset] = EMPTY_VALUE;
            Down_Arrow_Buffer[i-ArrowOffset] = High[i-ArrowOffset] + (ArrowDistance * Point);
            
         }
      
      else if (Close[i] < ((High[i] - Low[i])*45/100 + Low[i])&& Open[i] < ((High[i] - Low[i])*45/100 + Low[i]) && Close[i] > iMA(NULL,0,Length,0,MODE_EMA,0,i))
      {
         
            Down_Arrow_Buffer[i-ArrowOffset] = EMPTY_VALUE;
            Up_Arrow_Buffer[i-ArrowOffset] = Low[i-ArrowOffset] - (ArrowDistance * Point);
           
         }
      else
      {
         
         Up_Arrow_Buffer[i-ArrowOffset] = EMPTY_VALUE;
         Down_Arrow_Buffer[i-ArrowOffset] = EMPTY_VALUE;
         
        // RightSideCandleNum = 0;
      }
     
   }
//----
   return(0);
}

//+------------------------------------------------------------------+