Box filter based Exponential Moving Average
This EMA is designed to be identical to the EMA given in http://matplotlib.org/examples/pylab_examples/finance_work2.html however it is rolling (can be updated at any time). Because it is a rolling EMA, beware that the first n results will be different from the python example. This is because the python example uses result n + 1 for all results 0-n and since this algorithm is rolling, that is not possible. Discard the first n results and all following result will be the same.
To use:
const Ema = ; // Create an EMA with period 8const ema8 = Ema; 13579; console;console; console;console;
The python code on which this is based is as follows, note the commented line which is not possible with a rolling EMA.
weights = weights /= a = #a[:n] = a[n] ## This is not possible with a rolling EMA so it is removed. return a