Summarize:

Take all of your calculated returns and add them together. Then, divide by the number of returns you are using, n, to find the mean return. This represents the average return over the time period you are measuring. Specifically, the mean, m, is calculated as follows: m =(R1+R2+...Rn)/(n). For example, imagine that you had 5 periods that had calculated returns of 0.2, -0.1, -0.3, 0.4, and 0.1. You would add these together to get 0.3 then divide by the number of periods, n, which is 5. Therefore, your mean, m, would be 0.3/5, or 0.06. For every return, Rn, a deviation, Dn, from the mean return, m, can be found. The equation for finding Dn can be expressed simply as Dn=Rn-m. Complete this calculation for all returns within the range you are measuring. Using the previous example, you would subtract your mean, 0.06, from each of the returns to get a deviation for each. These would be: D1=0.2-0.06, or 0.14 D2=-0.1-0.06, or -0.16 D3=-0.3-0.06, or -0.36 D4=0.4-0.06, or 0.34 D5=0.1-0.06, or 0.04 Your next step is to find the mean variance of the returns by summing the squared individual deviations from the mean of the returns. The equation for finding the variance, S, can be expressed as: S=(D1^2+D2^2+...Dn^2)/(n-1). Again, sum the squares of the deviations, Dn, and divide by the total number of variances minus 1, n-1, to get your mean variance. First, square your deviations from the last step. These would be, in order: 0.0196, 0.0256, 0.1296, 0.1156, 0.0016. Sum these numbers to get 0.292. Then, divide by n-1, which is 4, to get 0.073. So, S=0.073 in the example. The volatility is calculated as the square root of the variance, S. This can be calculated as V=sqrt(S). This "square root" measures the deviation of a set of returns (perhaps daily, weekly or monthly returns) from their mean. It is also called the Root Mean Square, or RMS, of the deviations from the mean return. It is also called the standard deviation of the returns. In the example, this would just be the square root of S, which is 0.073. So, V=0.270. This number has been rounded to three decimal places. You may choose to keep more decimals to be more accurate. A stock whose price varies wildly (meaning a wide variation in returns) will have a large volatility compared to a stock whose returns have a small variation. By way of comparison, for money in a bank account with a fixed interest rate, every return equals the mean (i.e., there's no deviation) and the volatility is 0.
Find the mean return. Calculate the deviations from the mean. Find the variance. Calculate the volatility.