sum of absolute price change on a window

 

I want to calculate the sum of the absolute price change: this line works for 1 single bar: ExtMapBuffer0[i]=MathAbs(Close[i]-Close[i+1]) but to do it over several bars I guess I need to use a loop (with an adjustable window), any suggestions please?

int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
   {  
//----
   ExtMapBuffer0[i]=+MathAbs(Close[i]-Close[i+1]);
   //while(i<window) ??
   //{
   //ExtMapBuffer1[i]=;
   //}
//----
   }   
//----
   return(0);
  }

 
extern look.back = 3;
//----
//   ExtMapBuffer0[i]=+MathAbs(Close[i]-Close[i+1]);
   //while(i<window) ??
   //{
   //ExtMapBuffer1[i]=;
   //}
      ExtMapBuffer0[i] = 0;
   for (int j = i + look.back - 1; j>=i; j--)
      ExtMapBuffer0[i] += MathAbs(Close[j]-Close[j+1]);
//----
 
Thanks WHRoeder
Reason: