//+------------------------------------------------------------------+
//|                                             CustomWickWidth.mq5  |
//|  Draws only the high-low wick of each candle at a custom width,  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Custom"
#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   2

#property indicator_label1  "Wick_Bull"
#property indicator_type1   DRAW_HISTOGRAM2
#property indicator_color1  clrWhite;
#property indicator_label2  "Wick_Bear"
#property indicator_type2   DRAW_HISTOGRAM2
#property indicator_color2  clrWhite;

//--- Inputs
input int   Wick_Width = 3;   

//--- Buffers
double         Histogram_2Buffer1[];
double         Histogram_2Buffer2[];
double         Histogram_2Buffer3[];
double         Histogram_2Buffer4[];

//+------------------------------------------------------------------+
int OnInit()
{
   SetIndexBuffer(0,Histogram_2Buffer1,INDICATOR_DATA);
   SetIndexBuffer(1,Histogram_2Buffer2,INDICATOR_DATA);
   SetIndexBuffer(2,Histogram_2Buffer3,INDICATOR_DATA);
   SetIndexBuffer(3,Histogram_2Buffer4,INDICATOR_DATA);

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
   PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE);
   
   PlotIndexSetInteger(0, PLOT_LINE_WIDTH, Wick_Width);
   PlotIndexSetInteger(1, PLOT_LINE_WIDTH, Wick_Width);
   PlotIndexSetInteger(2, PLOT_LINE_WIDTH, Wick_Width);
   PlotIndexSetInteger(3, PLOT_LINE_WIDTH, Wick_Width);
      
   ArraySetAsSeries(Histogram_2Buffer1,true);
   ArraySetAsSeries(Histogram_2Buffer2,true);
   ArraySetAsSeries(Histogram_2Buffer3,true);
   ArraySetAsSeries(Histogram_2Buffer4,true);
   
   ChartSetInteger(0,CHART_FOREGROUND,0,true);

   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[])
{
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(close,true);

   for(int i = 0; i < rates_total; i++)
   {
         Histogram_2Buffer1[i]=EMPTY_VALUE;
         Histogram_2Buffer2[i]=EMPTY_VALUE;
         Histogram_2Buffer3[i]=EMPTY_VALUE;
         Histogram_2Buffer4[i]=EMPTY_VALUE;
         
      if(close[i] > open[i])
       {
         Histogram_2Buffer1[i]=low[i];
         Histogram_2Buffer2[i]=high[i];
         Histogram_2Buffer3[i]=EMPTY_VALUE;
         Histogram_2Buffer4[i]=EMPTY_VALUE;
       }
      else if(close[i] <= open[i])
       {
         Histogram_2Buffer3[i]=low[i];
         Histogram_2Buffer4[i]=high[i];
         Histogram_2Buffer1[i]=EMPTY_VALUE;
         Histogram_2Buffer2[i]=EMPTY_VALUE;
       } 
   }

   return(rates_total);
}
//+------------------------------------------------------------------+