A moving average is an analytical method in which an average price for a stock or commodity is computed over a period, or "window", that moves with time. Depending on trading frequency, the period can be hours, days, or months.
The purpose of the moving average is to smooth out short-term fluctuations in a graph in order to expose longer-term trends. Traditionally, the value of the moving average at a point in time is calculated from the period that precedes it; however, this results in the moving average lagging the original data by half of the period. The lag can be fixed by centering the window instead.
To calculate the moving average, look at the price over the past number of days. For instance, if over the past five days, the closing price of XYZ was $4.50, $4.59, $5.22, $5.11, and $5.36, then the 5-day moving average would be $4.96. On the following day, when the price was $5.29, the $4.50 would be dropped, and the remaining four plus the most recent would be averaged to come up with $5.11. The next day, the same thing would happen, dropping the $4.59, and including the next day's closing price. And so on.
Similar for the 50-day or 200-day moving average, except that those two average the last 50 or 200 days worth of prices. These are two commonly followed moving averages.
Moving averages are used by technical analysts to discover trends in stock prices. It's a method of evaluating stocks not usually used by long-term investors, as its focus is more on the movement of the stock price than on the fundamentals of the company. However, some investors use fundamental analysis to determine if a company is good enough to invest in, then use technical analysis to find good entry points.
Generally, a moving average is superimposed on a stock's line chart. If the stock price penetrates (crosses) the moving average on the upside (that is, crosses going from below to above) after a downward trend, this is considered a signal to buy. But if the stock price crosses the moving average from above to below, following an upward trend, the penetration is a bearish sign.