Historical Volatility Equation?

Discussion in 'Technical Analysis' started by cashonly, Apr 2, 2004.

  1. cashonly

    cashonly Bright Trading, LLC

    I'm looking for an equation to calculate the historical volatility of a stock based on a close to close basis.

    I know websites where I can find the actual volatility numbers.

    But, what I want is the equation to calculate these. Does anyone have it or can you point me in the right direction?


  2. Here is the formula for the historical log-normal vol. It can be used as an input to Black-Scholes. It's directly from McMillan's "Strategic" book, but written in Pascal-like WealthScript. Easy to convert to C.

    function LogVol(xdays, currentBar: integer):float;

    var AvgOfLns, SumOfAvgs: float;
    var count, i, endloop: integer;

    var Pratio: array[0..500] of float;
    var LNratio: array[0..500] of float;
    var Avgarray: array[0..500] of float;

    count := currentBar;
    AvgOfLns := 0.0;
    SumOfAvgs := 0.0;
    endloop := xdays - 1;

    for i := 0 to endloop do //Get ratio of Closes
    Pratio := PriceClose(count)/PriceClose(count - 1);
    count := count - 1;

    for i := 0 to endloop do //Take the LN and get average
    LNratio := LN(Pratio);
    AvgOfLns := AvgOfLns + LN(Pratio);

    AvgOfLns := AvgOfLns/xdays;

    for i := 0 to endloop do //Square difference and get average
    Avgarray := Sqr(LNratio - AvgOfLns);
    SumOfAvgs := SumOfAvgs + Sqr(LNratio - AvgOfLns);
    //Result is normalized to 1 year and expressed as a percent
    Result := Sqrt(SumOfAvgs/(xdays-1)) * Sqrt(250.0) * 100.0;

    end; //End LogVol function
  3. Cash, try my software system's site linnsoft.com. They might have it there under volatility wherein it explains indicators and how it is computed. Also, try peter hoadley's site. He is an options guru and has TONS of formulas.

  4. If price variation is supposed to be log normal (hmm, hmm... :D) it's simply the standard deviation of it : you can use STDEV in excel or for purist STDEVP (which just substract 1 day to the denominator of variance but if number of days is quite large above 100 it doesn't really make a practical diff), the formula of STDEV is no secret I think it's even in Excel Help file. Then multiplying by SQRT(250) days is strictly useless statistically speaking but it is the tradition in finance.