PureBytes Links
Trading Reference Links
|
Ah Sunday morning. An extra-large color version of the newspaper's comics and
one's mind turns towards thoughts of "and on the seventh day he rested." Not
being that "he," my mind turns towards a different version of volatility
calculation.
Back when I traded options for a living (dying?), I spent months researching
various volatility calculations and generated an entire file cabinet of copies
of academic post-doc papers discussing the topic. One 20 page paper would
calculate 1.345. Another 20 pager would be all new and improved and calculate
1.347. Whew. My mind reels in bliss. Only to fall to the floor dizzy and
exhausted.
But, there was one great improvement that I found which I coded in EasyLang
that worked well and did impart new information. That was a volatility
calculation by Rodgers and Satchell using open, high, low and close values.
Obviously if you just use the close you are discarding considerable
information. If you want to know more logic than that, don't ask me as I have
filed that memory far away along with having my wisdom teeth pulled, getting
dumped by a fashion model and buying a new car through a dealership. The
Rodgers and Satchell papers on the topic may be found in any university
business document library. I would enjoy hearing people's insights though. Have
fun!
{This code calculates an Open/High/Low/Close volatility as described by Rodgers
and Satchell}
Inputs:
NmbrDays(Numeric); {Number of days in sample size}
Vars:
SampleDays(0), {Population - 1}
Vlty1Day(0), {1 day volatility using OHLC}
Vara(0), {Variance, Vlty1Day squared}
Vlty(0), {Volatility over NmbrDays}
h1(0), {1/254}
a1(0), {SQRT(2*PI)*((1/4)-(SQRT(2)-1)/6))}
b1(0), {(1+(3*PI/4))/12}
LnOpen(0), {Natural log of the Open}
LnHigh(0), {Natural log of the High}
LnLow(0), {Natural log of the Low}
LnClose(0), {Natural log of the Close}
SqrA(0),SqrLnH(0),SqrLnL(0), {Formula}
Term1(0),Term2(0),Term3(0),Term4(0),
Term5(0),Term6(0),Term7(0),Term8(0); {Formula}
h1=0.003937008;
a1=0.45361049746;
b1=0.27968287418;
LnOpen = Log(Open);
LnHigh = Log(High);
LnLow = Log(Low);
LnClose = Log(Close);
SqrA = Square(a1);
SqrLnH = Square(LnHigh);
SqrLnL = Square(LnLow);
Term1 = (LnHigh-LnLow)*a1*SquareRoot(h1);
Term2 = SqrA*h1*SqrLnH - 2*SqrA*h1*LnHigh*LnLow + SqrA*h1*SqrLnL;
Term3 = SqrLnH - LnHigh*LnClose - LnOpen*LnHigh + 2*LnOpen*LnClose;
Term4 = SqrLnL - LnLow*LnClose - LnOpen*LnLow - 2*b1*h1*SqrLnH;
Term5 = 2*b1*h1*LnHigh*LnClose + 2*b1*h1*LnOpen*LnHigh - 4*b1*h1*LnOpen*LnClose
-2 *b1*h1*SqrLnL;
Term6 = 2*b1*h1*LnLow*LnClose + 2*b1*h1*LnOpen*LnLow;
Term7 = 1-2*b1*h1;
Term8 = Term2 + Term3 + Term4 + Term5 + Term6;
if Term8 < 0 then {Very very rare. Strange 0 movment flat bars}
Term8 = 0;
Vlty1Day = (Term1 + SquareRoot(Term8)) / Term7;
if NmbrDays > 1 then begin
SampleDays = NmbrDays - 1;
Vara = Square(Vlty1Day);
VolatilityOHLC = SquareRoot(Summation(Vara, NmbrDays) / SampleDays) *
15.93737745;
end else
VolatilityOHLC = Vlty1Day;
|