how to calculate 5 point moving average
Something like:
xavnew = xavold + (xi+1 - xi-5)/5
This assumes your first xav is based on the first five values of x, and that i is an index that points to the 5th value of the current value of xav, just prior to calculating the next value.
.