It is relatively easy to estimate the parameters of an autoregressive $AR(p)$ process. How do I do with a moving average $MA(q)$ process?
Estimating $MA(q)$ models is significantly harder than $AR(p)$ models. Eviews, MATLAB and R can use multiple algorithms which are all based on some form of maximum likelihood estimation. You can look at the source of MATLAB and R or the excellent Eviews documentation.
However, I strongly advise against rolling your own since efficient and well tested algorithms are widely available.