So, at the end of the day all you want is to average the first five incoming values and store the result in the context ? If this is the case you could alternatively try using the batch node along with the join node. The batch node would group each 5 messages, without overlap. The join node would be configured in the reduce mode. The help information of the join node shows how to average values. If that works you would not need to use the function node with complex code.
[{"id":"95869add.add8e8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"34578513.102c0a","type":"batch","z":"95869add.add8e8","name":"","mode":"count","count":"5","overlap":"0","interval":10,"allowEmptySequence":false,"topics":[],"x":350,"y":240,"wires":[["191888d6.f8a5a7"]]},{"id":"191888d6.f8a5a7","type":"join","z":"95869add.add8e8","name":"Average","mode":"reduce","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"$A+payload","reduceInit":"0","reduceInitType":"num","reduceFixup":"$A/$N","x":490,"y":240,"wires":[["5b3665cd.b82f0c"]]},{"id":"cf40d469.6e72d8","type":"inject","z":"95869add.add8e8","name":"","topic":"","payload":"1.93","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":160,"wires":[["34578513.102c0a"]]},{"id":"42b67723.f5fc18","type":"inject","z":"95869add.add8e8","name":"","topic":"","payload":"1.94","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":200,"wires":[["34578513.102c0a"]]},{"id":"cb97a1fa.c398f","type":"inject","z":"95869add.add8e8","name":"","topic":"","payload":"1.95","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":240,"wires":[["34578513.102c0a"]]},{"id":"586079a3.2b7738","type":"inject","z":"95869add.add8e8","name":"","topic":"","payload":"1.96","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":280,"wires":[["34578513.102c0a"]]},{"id":"a329c062.1979e","type":"inject","z":"95869add.add8e8","name":"","topic":"","payload":"1.88","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":320,"wires":[["34578513.102c0a"]]},{"id":"76059e54.a743","type":"debug","z":"95869add.add8e8","name":"Average","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":660,"y":300,"wires":[]},{"id":"5b3665cd.b82f0c","type":"change","z":"95869add.add8e8","name":"","rules":[{"t":"set","p":"offset","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":240,"wires":[["76059e54.a743"]]},{"id":"cab12b.d79baed8","type":"inject","z":"95869add.add8e8","name":"Read offset","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":460,"wires":[["5cf7613f.c676f"]]},{"id":"5cf7613f.c676f","type":"change","z":"95869add.add8e8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"offset","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":460,"wires":[["6a2b8243.c5041c"]]},{"id":"6a2b8243.c5041c","type":"debug","z":"95869add.add8e8","name":"offset","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":520,"y":460,"wires":[]}]