Array out of range error when use property strict!

 
 counted=IndicatorCounted();
   if(counted < 1)
      for(i=Bars - StartBar; i < Bars; i++)
        {
         TrLevelSlow[i]=0.0;
         AtrRsi[i]=0.0;
         MaAtrRsi[i]=0.0;
         Rsi[i]=0.0;
         RsiMa[i]=0.0;
        }
       
   counted=Bars - counted -1;  
//----
   for(i=counted; i>=0; i--)
      Rsi[i]=iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i);
   for(i=counted; i>=0; i--)
     {
      RsiMa[i]=iMAOnArray(Rsi, 0, SF, 0, MODE_EMA, i);     // ARRAY OUT OF RANGE Error??????
      AtrRsi[i]=MathAbs(RsiMa[i + 1] - RsiMa[i]);
     }
   for(i=counted; i>=0; i--)
      MaAtrRsi[i]=iMAOnArray(AtrRsi, 0, Wilders_Period, 0, MODE_EMA, i);
//----
  i=Bars-counted+3;
   tr=TrLevelSlow[i];
   rsi1=iMAOnArray(Rsi, 0, SF, 0, MODE_EMA, i);
   while(i > 0)
     {
      i--;
      rsi0=iMAOnArray(Rsi, 0, SF, 0, MODE_EMA, i);
      dar=iMAOnArray(MaAtrRsi, 0, Wilders_Period, 0, MODE_EMA, i) * 4.236;
      dv=tr;
      if (rsi0 < tr)
        {
         tr=rsi0 + dar;
         if (rsi1 < dv)
            if (tr > dv)
               tr=dv;
        }
      else if (rsi0 > tr)
           {
            tr=rsi0 - dar;
            if (rsi1 > dv)
               if (tr < dv)
                  tr=dv;
           }
      TrLevelSlow[i]=tr;
      rsi1=rsi0;
     }
 if ((RsiMa[i+1]<AlertLevel && RsiMa[i]>AlertLevel  )
 ||(RsiMa[i+1]>AlertLevel && RsiMa[i]<AlertLevel) )
  {for(shift=0,y=0;shift<limit-1;shift++)
   {
   if (Time[shift]<TimeArray[y]) y++;

   if (CCI0>0 && CCI1<=0) 
     
     {if(!HISTOGRAM) UpArr[shift]=0;
      if(shift==0) Alerts(ZeroBuyAlert);    
      }
      
      
       base=Symbol()+ ", TF: " + TF2Str(Period());
       Subj=base + ", " + AlertLevel + " Both QQE&CCI Up,BUY";
      
      }
   if (RsiMa[i+1]>AlertLevel&& RsiMa[i]<AlertLevel)
 
     
 
Subj=base + " " +  AlertLevel+ " Both QQE&CCI Down,SELL";
      
    
       Msg=Subj + " @ " + TimeToStr(TimeLocal(),TIME_SECONDS);
      if (Bars>LastAlertBar)
        {
         LastAlertBar=Bars;
         DoAlerts(Msg,Subj);
        }
     
     
   }
   
 
Hoang Anh Khoa:

WHEN I TRY TO COMPLITE AND RUN WITH STRICT MODE,IT HAS ERROR AND INDICATOR CORRUPT .WHO HAS EXPERIENCE ABOUT IT.THANKS


for(shift==0,y=0;shift<limit-1;shift++)
 
Vitaly Muzichenko #:
Mr Muzichenko it doesn't work. You have another way?
 
Hoang Anh Khoa: WHEN I TRY TO COMPLITE AND RUN WITH STRICT MODE,IT HAS ERROR AND INDICATOR CORRUPT .WHO HAS EXPERIENCE ABOUT IT.THANKS

 if ((RsiMa[i+1]<AlertLevel && RsiMa[i]>AlertLevel  )
 ||(RsiMa[i+1]>AlertLevel && RsiMa[i]<AlertLevel) )
  {for(shift=0,y=0;shift<limit;shift++) 
  1. Don't SHOUT at us, that is very RUDE.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum (2019)
              Messages Editor

  3. Always post all relevant code (using Code button) or attach the source file.  We have no idea what i, limit, DnArr, or UpArr are. That is where your problem lies.
         How To Ask Questions The Smart Way. (2004)
              Be precise and informative about your problem

  4. Do your lookbacks correctly #9#14 & #19

    .
 

Maybe the problem is here

counted=IndicatorCounted();                             // counted = 0
   if(counted < 1)
      for(i=Bars - StartBar; i < Bars; i++)
        {
         TrLevelSlow[i]=0.0;
         AtrRsi[i]=0.0;
         MaAtrRsi[i]=0.0;
         Rsi[i]=0.0;
         RsiMa[i]=0.0;
        }
       
   counted=Bars - counted -1;                           // Bars = 100
                                                        // counted = 99
//----
   for(i=counted; i>=0; i--)
      Rsi[i]=iRSI(NULL, 0, RSI_Period, PRICE_CLOSE, i);
   for(i=counted; i>=0; i--)
     {
      RsiMa[i]=iMAOnArray(Rsi, 0, SF, 0, MODE_EMA, i);
      AtrRsi[i]=MathAbs(RsiMa[i + 1] - RsiMa[i]);       // i = 99
                                                        // i + 1 = 100 (the index of the last bar is 99)
     }
 
  1. Vladislav Boyko #: Maybe the problem is here
       counted=Bars - counted -1;                           // Bars = 100
    ⋮
          AtrRsi[i]=MathAbs(RsiMa[i + 1] - RsiMa[i]); 

    When IndicatorCounted() is zero, counted is Bars-1. RsiMa[i+1] is RsiMa[Bars] which does not exist.

  2. Do your lookbacks correctly #9#14 & #19

  3. You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

 
William Roeder #:
  1. Do your lookbacks correctly #9#14 & #19

  2. You should stop using the old event handlers (init, start, deinit) and IndicatorCounted() and start using new event handlers (OnInit, OnTick/OnCalculate, OnDeinit).
              Event Handling Functions - MQL4 Reference
              How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 (2016)

Thank you, but I am not the author of the code and the author of this topic. I just suggested where the author of the code could have an array out of range error.

Reason: