You probably could do this using graphical patch & variadic node with a buffer node, but you will need dummy pins to pass count & total to each level and the variadic pins would also be dummy pins. It would be a lot easier to implement in C++ using a FIFO queue (First In - First Out). A google search will give you lots of ways to implement the FIFO queue and references to standard C++ library implementation (which I would assume is available from XOD).
If you want to hard-code for a specific sample size, then you could create a patch with that number of cascading buffers to store the values. Note that the pulse needs to run backwards through the buffers to keep old values instead of filling all buffers with new value. Not sure what will happen to output of average while the buffers are updating, I’m guessing it will update as each buffer is updated unless you have a buffer on the output also.
Hmmm…the fact that buffer doesn’t have an output pulse makes it a bit harder to implement this…I assume you would have to use defer-pulse to connect the buffers…
This might do what you want for 3 samples: