Good question, lots of people have confusion in understanding how to calculate Moving averages. Here's a excel spreadsheet where I have calculated moving average of Nifty index (Indian markets).
The spreadsheet has 10,20,50,100 and 200 day moving averages. The formula is simple - for any given day, take the last 10,20,50,100,200 observations respectively just before that day and calculate a simple average using excel function average(). That is your average. When you do the calculation of next day, you get a new average, and so now you have your moving average series. Check it out, quite simple.