I agree with @Christoph that python makes this much easier. Here is an example of how to compute the running stdev in python:
#!/usr/bin/env python2.7
import argparse
parser = argparse.ArgumentParser(description='Computes a moving standard deviation for a data file')
parser.add_argument('--number', '-n', help='Window size (number of points to either side)', type=int)
parser.add_argument('dataFile', help='Name of data file', type=str)
args = parser.parse_args()
n = args.number
# I hope you have numpy, it makes things much easier
import numpy as np
# assuming two-column time/datum format
data = np.loadtxt(args.dataFile)
for ii in range(n,len(data)-n):
print data[ii,0], np.std(data[ii-n:ii+n+1,1])
Now you can call the script on the data file from gnuplot:
plot '<python boxcarStdev.py -n 5 mydata.dat'