Please help Pinbar Indicator

I have an indicator that I put together following a video tutorial. It identifies pinbars on the chart and plots an arrow above(for bearish pinbar) and below(for bullish pinbar). I’m trying to have that the indicator only to plot an arrow where the pinbar’s wick happens to form the new high/low of the day. This high/low also has to be higher/lower than the previous day’s high/low respectively. How to tweak it?

//+------------------------------------------------------------------+
//|                                            Mcgee's indicator.mq4 |
//|                                                  McNilly Goshomi |
//|                                         mcnillygoshomi@gmail.com |
//+------------------------------------------------------------------+
#property copyright "McNilly Goshomi"
#property link      "mcnillygoshomi@gmail.com"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 clrGreen
#property indicator_color2 clrRed
#property  indicator_width1 2
#property  indicator_width2 2
//--- input parameters
extern double bmi=25.0;
double up[];
double down[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   bmi*=.01;
//--- indicator buffers mapping
      SetIndexBuffer(0,up);
      SetIndexStyle(0,DRAW_ARROW);
      SetIndexArrow(0,233);
      SetIndexLabel(0,"Up Arrow");

      SetIndexBuffer(1,down);
      SetIndexStyle(1,DRAW_ARROW);
      SetIndexArrow(1,234);
      SetIndexLabel(1,"Down Arrow");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])

  {
         int limit = MathMax(rates_total-prev_calculated,2);
         for (int i=1;i<limit;i++)
         {
          double total=High[i]-Low[i];
          double body=MathAbs(Open[i]-Close[i]);
          double maxSize=total*bmi;
          if (body<maxSize
              &&Open[i]<Close[i]
              &&High[i]-Open[i]<maxSize
              &&Low[i]<Low[i+1]
              &&Low[i]<Low[i+2])
              up[i]=Low[i];
      else if(body<maxSize
              &&Open[i]>Close[i]
              &&High[i]-Close[i]<maxSize
              &&Low[i]<Low[i+1]
              &&Low[i]<Low[i+2])
              up[i]=Low[i];
      else if(body<maxSize
              &&Open[i]>Close[i]
              &&Open[i]-Low[i]<maxSize
              &&High[i]>High[i+1]
              &&High[i]>High[i+2])
              down[i]=High[i];
      else if(body<maxSize
              &&Open[i]<Close[i]
              &&Close[i]-Low[i]<maxSize
              &&High[i]>High[i+1]
              &&High[i]>High[i+2])
              down[i]=High[i];
         }
//---


//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
```