Average of a buffer

 
Is there a "simple" way to compute, bar-by-bar, the average of a buffer? My custom indicator returns a double value for every bar on the chart. Starting with the first bar on the left, I'd like to average all the data in the buffer for the amount of bars, e.g. on the first bar, return an average of the first bar's data, on the second bar return an average of the first two bars of data, on the n'th bar return the average of the n bars of the buffer?