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

[amibroker] Z Score



PureBytes Links

Trading Reference Links

Hi Pal --

There is one interpretation of the Z-Score that takes an observation from a
population and returns a Z-Score statistic, where the Z-Score is a
measurement of the number of standard deviations that that specific
observation deviates from the mean.  If this is the interpretation you
intend, the following afl code returns the Z-Score of the Close of the most
recent 50 days of an end-of-day price series and plots it.  Copy this code
and paste it into Indicator Builder.


//-------------------------

//	ZScore of Close
//
 
ZLen = 50;
ZScore = (C-MA(C,ZLen))/StDev(C,ZLen);

Plot(C,"C",colorBlack,style=styleCandle);

Plot(ZScore,"ZScore",colorBlue,styleOwnScale|styleNoLabel,-3,3);

Plot(0,"",colorRed,styleOwnScale|styleNoLabel,-3,3);
Plot(-2.0,"", colorRed,styleOwnScale|styleNoLabel,-3,3 ); 
Plot(2.0,"", colorRed,styleOwnScale|styleNoLabel,-3,3);

//-------------------------

Note that most of the Closes (95 percent, on average) will have ZScore
values between -2.0 and +2.0.

My apologies if I misinterpreted your request.

Howard

/////-----------------------------   
   
   
   Date: Fri, 19 Sep 2003 19:01:08 -0000
   From: "palsanand" <palsanand@xxxxxxxxx>
Subject: Z-Score

Hi,

I was looking for an algorithm that will tell me the z-score of a 
given percentile. In other words, I was looking for an algorithm 
that will replicate a reverse lookup in a normal distribution table.

Abramowitz & Stegun is my friend ("Handbook of Mathematical
Functions"). Formula 26.2.22 gives an approximation in z accurate to
within 3e-3, and formula 26.2.23 gives a more complicated but more
accurate formula.

26.2.22 says this (in pseudo-Fortran). p appears to be the
*upper*-tail probability (ie. p=P(Z>z)) and has to be less than 0.5
for this to work. (If not, call the function with argument 1-p and 
put
a minus sign on the result.)

t=sqrt(ln(1/p**2))  [ p squared ]
a0=2.30753
a1=0.27061
b1=0.99229
b2=0.04481
z=t-(a0+a1*t)/(1-t*(b1+b2*t))

The problem is to implement this efficiently in AB.  Ay ideas?
Thanks,
Pal



------------------------ Yahoo! Groups Sponsor ---------------------~-->
ReplayTV: Control live television
Special Sale: 50% off ReplayTV
CNet Ranked #1 over Tivo!
http://us.click.yahoo.com/aUMW7B/A6qGAA/ySSFAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/