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

Re: Volatility & Predicting Future Range


  • To: omega-list@xxxxxxxxxx
  • Subject: Re: Volatility & Predicting Future Range
  • From: archer@xxxxxxx
  • Date: Mon, 16 Feb 1998 15:41:36 -0800 (PST)
  • In-reply-to: <cvinton@xxxxxxxxxxxxxx>

PureBytes Links

Trading Reference Links


>
>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):
>
<snip>

Here's two indicators, separated by {***************}

{"Volatility" plots Current, Highest, Lowest and Mean (midpoint between 
highest - lowest of the Lookback period) Volatility.  Note:  On the first 
bar of the Lookback period, Highest, Lowest and Mean should all equal 
Current.  Sometimes, Lowest equals zero.  In this event just increase the 
lookback by 1, until it is correct.}

{ Volatility }
Inputs: VolPer(20),EndDate(0),Lookback(365);

Vars: HVol(0),NLog(0),PC(0),EDate(0),
MyVol(0),HMyVol(0),LMyVol(0),MMyVol(0),ABar(0);

If DataCompression <= 2 then begin

If Close[1]<>0 Then PC = (Close / Close[1]) Else PC = 1;
NLog = Log(PC);
HVol = StdDev(NLog,(VolPer)) * SquareRoot(365);
MyVol= HVol * 100;

Plot1(MyVol,"Vola");

If EndDate <> 0 then EDate = EndDate
else EDate = LastCalcDate;

Value1 = DateToJulian(EDate);
Value2 = Value1 - Lookback;
If Date = JulianToDate(Value2) then ABar = CurrentBar;

If Date >= JulianToDate(Value2) and Date <= Edate then begin
If CurrentBar = ABar then begin
   HMyVol = MyVol;
End Else 
   If MyVol >= HMyVol[1] then
      HMyVol = MyVol
	Else
      HMyVol = HMyVol[1];

If CurrentBar = ABar then begin
   LMyVol = MyVol;
End Else
   If MyVol <= LMyVol[1] then
      LMyVol = MyVol
	Else
      LMyVol = LMyVol[1];

MMyVol = LMyVol + ((HMyVol - LMyVol) / 2);

Plot2(HMyVol,"HVol");
Plot3(LMyVol,"LVol");
Plot4(MMyVol,"MVol");
End;
End;

{*************************************}

{Probable Range allows input of a StrtDate, number of days in the future for 
"Forecast", desired probability in increments of 5 - "Prob(85)" is 85% 
probability (~1 standard deviation), "Mean(true)" the indicator will use the 
greater of "Current Volatility" or "Mean Volatility" of period "Lookback".  
An input greater than zero for "Vola" (Volatility) will override 
"Mean(true)".  "VolPer(20)" is the Volatility Period.  20 trading days 
approximates 30 calendar day volatility.}


{ Probable Range }
Inputs: StrtDate(971017),Forecast(30),Prob(85),Mean(true),Vola(0),
		VolPer(20),Lookback(365),Price(Close),ShowPRH(True),ShowPRL(True);

Vars:	PC(0),NLog(0),HVol(0),MyVol(0),HMyVol(0),LMyVol(0),
		MMyVol(0),ABar(0),Vol(0),PRHC(0),PRLC(0),Factor(0);
		
If DataCompression = 2 then begin

If Price[1]<>0 Then PC = (Price / Price[1]) Else PC = 1;
NLog = Log(PC);
HVol = StdDev(NLog,(VolPer)) * SquareRoot(365);
MyVol= HVol * 100;

Value1 = DateToJulian(StrtDate);
Value2 = Value1 - Lookback;
If Date = JulianToDate(Value2) then ABar = CurrentBar;

If CurrentBar = ABar then begin
   HMyVol = MyVol;
End Else 
   If MyVol > HMyVol[1] then
      HMyVol = MyVol
   Else
      HMyVol = HMyVol[1];

If CurrentBar = ABar then begin
   LMyVol = MyVol;
End Else
   If MyVol < LMyVol[1] then
      LMyVol = MyVol
   Else
      LMyVol = LMyVol[1];

MMyVol = LMyVol + ((HMyVol - LMyVol) / 2);
End;	

If Mean = True and Vola = 0 then begin
 If MMyVol > MyVol then Vol = MMyVol
	else Vol = MyVol;
end else

If Mean = False and Vola = 0 then begin
 Vol = MyVol;
end else

If Vola > 0 then begin
 Vol = Vola;
end;

If Prob = 50 then factor = 0
 else If Prob = 55 then factor = .125661
 else If Prob = 60 then factor = .253347
 else If Prob = 65 then factor = .385321
 else If Prob = 70 then factor = .524401
 else If Prob = 75 then factor = .67449
 else If Prob = 80 then factor = .841621
 else If Prob = 85 then factor = 1.036433
 else If Prob = 90 then factor = 1.281551
 else If Prob = 95 then factor = 1.644853;


If Date = StrtDate then begin
	PRHC = Price * ExpValue((Vol / 100) * SquareRoot(Forecast / 365) *  factor);
end;

If Date = StrtDate then begin
	PRLC = Price * ExpValue((Vol / 100) * SquareRoot(Forecast / 365) * - factor);
end;

Value1 = DateToJulian(StrtDate);
Value2 = Value1 + Forecast;

If ShowPRH = true then begin
If PRHC > 0 and Date <= JulianToDate(Value2) then
Plot1(PRHC,"PRH");
end;	
If ShowPRL = true then begin
If PRLC > 0 and Date <= JulianToDate(Value2) then
Plot2(PRLC,"PRL");
end;