Download MetaTrader 5

Can someone explain the logic behind this? counted_bars and Avgrange

To add comments, please log in or register
basosm
8
basosm  

Can someone please explain the logic behind this, I just began learning mql and I cant seem to understand why is this found in almost all the codes I have read so far.

//---- check for possible errors
   if(counted_bars<1) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;
   
   for(i = 0; i <= limit; i++) {
   
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-High[counter]);
      } 

      Range=AvgRange/10; 

To add comments, please log in or register