//+------------------------------------------------------------------+
//|                                                    ThickWick.mq4 |
//|                      Copyright c 2004, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//|                                        Based on Heiken Ashi Code |
//|                                                    Linuxser 2007 |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| For CustomCandle I recommend next chart settings ( press F8 or   |
//| select on menu 'Charts'->'Properties...'):                       |
//|  - On 'Color'  Tab select 'None' for 'Line Graph'                |
//|  - On 'Common' Tab disable 'Chart on Foreground' checkbox and    |
//|    select 'Line Chart' radiobutton                               |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 6

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];

//----
extern int CandleWidth = 3;
extern int WickWidth = 1;
extern color BullCandle = clrSpringGreen;
extern color BearCandle = clrCrimson;
extern color BullWick = clrDarkGray;
extern color BearWick = clrDarkGray;
extern color HighLowColor = clrDarkGray;


int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, WickWidth, BearWick);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexLabel (0, NULL);
   SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, WickWidth, BullWick);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexLabel (1, NULL);
   SetIndexStyle(2,DRAW_HISTOGRAM, EMPTY, CandleWidth, BearCandle);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexLabel (2, NULL);
   SetIndexStyle(3,DRAW_HISTOGRAM, EMPTY, CandleWidth, BullCandle);
   SetIndexBuffer(3, ExtMapBuffer4);
   SetIndexLabel (3, NULL);
   SetIndexStyle(4,DRAW_HISTOGRAM, EMPTY, EMPTY);
   SetIndexBuffer(4, ExtMapBuffer5);
   SetIndexLabel (4, NULL);
   SetIndexStyle(5,DRAW_HISTOGRAM, EMPTY, WickWidth, HighLowColor);
   SetIndexBuffer(5, ExtMapBuffer6);
   SetIndexLabel (5, NULL);
   
   IndicatorShortName("Thick Wick");
//----
  
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   double haOpen, haHigh, haLow, haClose;
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
   while(pos>=0)
     {
      haOpen=Open[pos];
      haClose=Close[pos];
      haHigh=High[pos];
      haLow=Low[pos];
      if (haOpen<haClose) 
        {
         ExtMapBuffer1[pos]=haLow;
         ExtMapBuffer2[pos]=haHigh;
         ExtMapBuffer5[pos]=EMPTY_VALUE;
         ExtMapBuffer6[pos]=EMPTY_VALUE;
        }
 
      else
        {
         ExtMapBuffer1[pos]=haHigh;
         ExtMapBuffer2[pos]=haLow;
         ExtMapBuffer5[pos]=EMPTY_VALUE;
         ExtMapBuffer6[pos]=EMPTY_VALUE; 
        }          
        
      ExtMapBuffer3[pos]=haOpen;
      ExtMapBuffer4[pos]=haClose;
      
      if (haOpen==haClose) 
        {
         ExtMapBuffer5[pos]=haLow;
         ExtMapBuffer6[pos]=haHigh; 
         ExtMapBuffer1[pos]=EMPTY_VALUE;
         ExtMapBuffer2[pos]=EMPTY_VALUE; 
         ExtMapBuffer3[pos]=EMPTY_VALUE;
         ExtMapBuffer4[pos]=EMPTY_VALUE;                 
        }       
 	   pos--;
     }
//----
   return(0);
  }
//+------------------------------------------------------------------+