Indicator not updating with every new bar please help

 
//+------------------------------------------------------------------+
//|                                            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

double up[];
double down[];
datetime currentime=0;
datetime candletime=0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
  
//--- 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[])
                
  {      
          double CurrentDayLow= iLow(Symbol(), PERIOD_D1, 0);
         double CurrentDayHigh= iHigh(Symbol(), PERIOD_D1, 0);
         double PreviousDayOpen= iOpen(Symbol(),PERIOD_D1, 1);
          double PreviousDayClose= iClose(Symbol(),PERIOD_D1, 1);
          double PreviousDayLow= iLow(Symbol(), PERIOD_D1, 1);
           double PreviousDayHigh= iHigh(Symbol(), PERIOD_D1, 1);
            currentime=Time[0];
            //int limit=Bars-1-IndicatorCounted()-100;
        int limit = MathMax(rates_total-prev_calculated,2);
         for (int i=1;i<limit-3;i++)
         {
       
       double ccr= High[i]-Low[i];
         double c1r= High[i+1]-Low[i+1];
         double c2r= High[i+2]-Low[i+2];
          double c3r= High[i+3]-Low[i+3];
           double c4r= High[i+4]-Low[i+4];
            double c5r= High[i+5]-Low[i+5];
             double c6r= High[i+6]-Low[i+6];
              double c7r= High[i+7]-Low[i+7];
               double c8r= High[i+8]-Low[i+8];
                double c9r= High[i+9]-Low[i+9];
                 double c10r= High[i+10]-Low[i+10];
          if (ccr>c1r
          &&ccr>c2r
          &&ccr>c3r
          &&ccr>c4r
          &&ccr>c5r
          &&ccr>c6r
          &&ccr>c7r
          &&ccr>c8r
          &&ccr>c9r
          &&ccr>c10r
          &&Open[i]>Close[i]
          &&Close[i]<=Low[i]+ ccr * 0.3
          
              )
          {
              up[i]=Low[i];
              
            if(Low[i] == CurrentDayLow
            &&PreviousDayClose>PreviousDayOpen
           && currentime!=candletime
           && i==1
            )
            {
            
               Alert((string)Period()+ "M ",Symbol()," "+"Possible bullish setup forming!");
               SendNotification((string)Period()+"M"+Symbol()+" "+"Possible bullish setup forming!" );
               
            }
            candletime=Time[0];
          }
           else if (ccr>c1r
          &&ccr>c2r
          &&ccr>c3r
          &&ccr>c4r
          &&ccr>c5r
          &&ccr>c6r
          &&ccr>c7r
          &&ccr>c8r
          &&ccr>c9r
          &&ccr>c10r
          &&Open[i]<Close[i]
          &&Close[i]>=High[i]- ccr * 0.3
          
              )
          {
              down[i]=High[i];
              
            if(High[i] == CurrentDayHigh
           &&PreviousDayClose<PreviousDayOpen
           && currentime!=candletime
           && i==1
            )
            {
            
               Alert((string)Period()+ "M ",Symbol()," "+"Possible bearish setup forming!");
               SendNotification((string)Period()+"M"+Symbol()+" "+"Possible bearish setup forming!" );
               
            }
            candletime=Time[0];
            
          }
     
              
         }
//---
 

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
  int limit = MathMax(rates_total-prev_calculated,2);
         for (int i=1;i<limit-3;i++)
What are thinking this is doing ?
 
  1.         int limit = MathMax(rates_total-prev_calculated,2);
             for (int i=1;i<limit-3;i++)
                     ⋮
                     double c10r= High[i+10]-Low[i+10];
    Do your lookbacks correctly. Your maximum lookback is ten (10.) Generally count down do you don't access future bar values.
              How to do your lookbacks correctly #9 - #14 & #19

  2.           double CurrentDayLow= iLow(Symbol(), PERIOD_D1, 0);

    On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

  3. You are mixing apples and oranges.