[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Volatility & Predicting Future Range



PureBytes Links

Trading Reference Links

Date:  95-10-02 13:49:53 EDT
From:  JRehler

I assume that you are referring to the volatility equation that is used in calculating options
premiums. Here is my user function for calculating volitility.  You may of course thank me
profusely for the code.  Wouldn't it be nice if others were so forth coming?  I think the more
examples of code you see the better you are able to code and test your theories.  I encourage
others to publish their code so we all will benefit.

(You must name the user function MyVolatility or change the code to a new name)}

Inputs : Price(NumericSeries),Length(NumericSimple);
Vars    : SumSqr(0),Counter(0),R(0),vari(0),yr_var(0),
 N(1);

If Length <> 0 then Begin
  SumSqr = 0;
  R = 0;
  vari = 0;
  yr_var = 0;
  N = 1;

  For counter = 1 to Length begin
    R = (Price[counter] - Price[counter + 1]) / Price[counter + 1];
    r = Log(1 + R);
    SumSqr = SumSqr + (r - Log(1 + Average(R,Length) ) ) *  (r - Log(1 + Average(R,Length) ) );
  End;

  vari = SumSqr / (Length - 1);
  If DataCompression = 2 then N = 252
    Else If DataCompression = 3 then N = 52
    Else If DataCompression = 4 then N = 12;
  yr_var = vari * N;

VolatilityX = SquareRoot(yr_var);
End
Else
 VolatilityX = 0;





Gary Funck wrote:

> if volatility is calculated in the way that is conventional for
> the "statistical" volatility used in McMillan's and Natenberg's
> books on options, then volatility is the annualized standard
> deviation of of the log of the daily returns.  I don't have
> the EL code for this, but it might look something like this
> (I have tried verifying this code, if you get it working, please
> post your solution to the group):
>
> { function statvol - statistical volatility }
> inputs: P(numericseries), N(numericsimple);
> vars: logr(0);
>    logr = log(P/P[1]);
>    if currentbar > N the begin
>        { we can't compute statvol until we have enough data }
>        statvol = StdDev(logr, N) * SquareRoot(260.0) * 100.0;
>    end else begin
>        statvol = 20.0; { some number }
>    end;
>
> (I wasn't too sure about the need to check for currentbar above,
> or whether specify the input price, P, as a series or not.  Any
> suggestions on a better way to write this function in EL?)
>
> Given the annual volatility, 25% in your example, the anticipated
> range (1 std. dev.) with an approximate prob. of 70% of the price
> finishing in that range, is given as:
>
>      one_std_dev_as_pct = exp(annual_vol_as_pct * sqrt(N / 260)) - 1.0
>
> for v = 25%, and N = 20, the anticipated 1 std. dev. range is:
>         exp(0.25 * sqrt(N / 260)) - 1.0 => 0.07
> thus, at this 25% vol. level, there's a 70% chance the price will
> be in the range of the current price +/- 7%.  Two standard deviations
> give a 95% confidence, and that would come out to +/- 14%, or
> between 17.2 and 22.8 for a stock trading at 20.
>
> If your measure of volatility doesn't use the log function, but
> just a straight annualized std. dev., this calculation should work:
>    one_std_dev_as_pct = annual_vol_as_pct * sqrt(N / 260)
>
> (above, N, is measured in trading days, and 260 is an approx. for
> the number of trading days in a year.)
>
> > Subject: Re: Volatility & Predicting Future Range
> > Cab Vinton wrote:
> > > Given an asset's present volatility, it should be a
> > > fairly simple matter to predict the future range of
> > > that asset N days into the future.
> >
> > Sure. Look in your indicator tool box for Bollinger or Standard
> > deviation formulas. These indicators predict statistical range
> > based on exactly what you are talking about. :)
>
> --
> --
> | Gary Funck,  Intrepid Technology, gary@xxxxxxxxxxxx, (650) 964-8135