Without input it's really difficult to understand what you are trying to achieve, Here is an example of moving average of 5 point and index at 3, implement according to your need
awk '
BEGIN{
OFS = "\t"
No_of_row = 20
Average_Point = 5
index_Point = 3
print "Column1" OFS "Column2"
for(i=1;i<=No_of_row;i++)
{
C1[i]=i
C2[i]=i
print i OFS i
}
print RS "index" OFS "Average" OFS "Data_used" OFS "Sum" OFS "No_of_Point"
}
END{
for(i=1;i<=No_of_row;i++){
for(j=1;j<=Average_Point;j++){
flag = 0
if(C1[i+j] || j == 1 && C1[i])
{
add = j==1 ? C2[i] : C2[(i+j)-1]
sum += add
ind = j==index_Point ? C1[(i+j)-1] : ind
flag = 1
s = s ? s "+" add : add
}
}
if(flag == 1){
print ind,sum/Average_Point,s,sum,Average_Point
}
sum = ind = s = ""
}
}
' /dev/null
Resulting
Column1 Column2
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
index Average Data_used Sum No_of_Point
3 3 1+2+3+4+5 15 5
4 4 2+3+4+5+6 20 5
5 5 3+4+5+6+7 25 5
6 6 4+5+6+7+8 30 5
7 7 5+6+7+8+9 35 5
8 8 6+7+8+9+10 40 5
9 9 7+8+9+10+11 45 5
10 10 8+9+10+11+12 50 5
11 11 9+10+11+12+13 55 5
12 12 10+11+12+13+14 60 5
13 13 11+12+13+14+15 65 5
14 14 12+13+14+15+16 70 5
15 15 13+14+15+16+17 75 5
16 16 14+15+16+17+18 80 5
17 17 15+16+17+18+19 85 5