Arrows not painted in real time

 

This code wont paint arrow in real time. I know there is one loop needed for checking current running candle but firstly I don't understand what this "void clearmarks" function does? And can I write a new loop into "void CheckNPB" ?

double CalRange(int bar_num, bool verify=false)
{
   int counter, n=0;
   double Range, AvgRange; 
   if (verify) n=1;
   AvgRange=0;
   for (counter=bar_num-n; counter<=bar_num+1;counter++)
   {
      AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
   }
   Range=AvgRange/2;
   return(Range);
}

void clearmarks(double& NPB[])
{
   for (int i=0; i<= Bars-1; i++)
   {
      NPB[i]=0;
   }
   return;
}

void CheckNPB(int bar_num, double& NPB[], bool& downalert, bool verify=false)
{
   double bar_length, nose_length, body_length;

   if(CheckPinBars)
   {
      bar_length = High[bar_num]-Low[bar_num];
      if (bar_length==0) bar_length=0.0001;
      nose_length = High[bar_num]-MathMax(Open[bar_num], Close[bar_num]);
      body_length = MathAbs(Open[bar_num]-Close[bar_num]);

      if( 
         nose_length/bar_length > Min_Nose_Ratio/100.0 &&
         body_length/bar_length < Max_Body_Ratio/100.0 &&
         (High[bar_num]-High[bar_num+1]>=bar_length/3.0 || 
         (High[bar_num]-High[bar_num+1]>=bar_length/4.0 &&
          body_length/bar_length<0.2)) &&
          Low[bar_num]>Low[bar_num+1])
      {
         if(History) NPB[bar_num]=High[bar_num]+0.1*CalRange(bar_num, verify);
         
         if(Alerts && !downalert && !startup && !verify) 
         { 
            Alert ("PriceAction AHA on ", Symbol()," "+timeframe+": Negative Pin Bar!! ");
            SendMail("PriceAction AHA: Pin Bar on "+Symbol()+" "+timeframe+"!!", "PriceAction AHA: Negative Pin bar found on "+Symbol()+" "+timeframe+"!!");

            downalert=true;
         }
      }
   
      if(verify&&(!(nose_length/bar_length > Min_Nose_Ratio/100.0 &&
                    body_length/bar_length < Max_Body_Ratio/100.0 &&
                    (High[bar_num]-High[bar_num+1]>=bar_length/3.0 || 
                    (High[bar_num]-High[bar_num+1]>=bar_length/4.0 &&
                     body_length/bar_length<0.2)) &&
                     Low[bar_num]>Low[bar_num+1]) ||
                     High[bar_num]<High[bar_num-1])) 
            NPB[bar_num]=0;
      
      if(verify) 
      {
         downalert=false;
      }
   }   
   return;
}