help me ! how to fix yearly to weekly

 
   int    pos=0;
   int    counted_bars=IndicatorCounted();
   actualyear=TimeYear(iTime(NULL,PERIOD_MN1,0));
  // if(counted_bars < 0) 
     //   return(-1);
//---- last counted bar will be recounted
    if(counted_bars > 0) 
        counted_bars--;
    pos = 0;
    
    while(actualyear-TimeYear(iTime(NULL, PERIOD_MN1, pos))<=1)
    {
      if(actualyear-TimeYear(iTime(NULL, PERIOD_MN1, pos))==1)
      {
         if(iHigh(NULL,PERIOD_MN1,pos)>highi)
            highi=iHigh(NULL,PERIOD_MN1,pos);
         if(iLow(NULL,PERIOD_MN1,pos)<lowi)
            lowi=iLow(NULL,PERIOD_MN1,pos);
         if(TimeMonth(iTime(NULL, PERIOD_MN1, pos))==12)
            closei=iClose(NULL,PERIOD_MN1,pos);
      }
            
      pos++;
    }