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

[amibroker] Re: Sector and industry analysis



PureBytes Links

Trading Reference Links

Hi,

The Central Limit Theorem states:

If a large number of random samples (of size 30 or more) are 
collected, the means from a sampling distribution of means where 

a)  the mean of the sample will be equal to the mean of the population

b)  The StDev of the sampling distribution is the standard error of 
the mean and 

c)  when n is large (> 30) the sampling distribution of means is 
approximately normally distributed regardless of the shape of the 
distribution of the population as long as the sample size of each 
sample is the same.

Z-Scores of the COT data can be combined with the Z-Scores of the 
close price to accurately pinpoint turning points.  But, I would 
still detect, verify and interpret a Entry/Exit Trading Signal for 
precise timing.

I also modified plots for the following code to indicate whether the 
Bands have been crossed, which would warn me to look for a trading 
signal, whether a continuation signal or counter-trend 
pullback/Breakout signal:

/* Anticipating the next bar BBandBot OR BBandTop Cross, by D. 
Tsokakis, Sept 2003.  Both crosses come from the same 2nd degree 
equation A2*X^2+A1*X+A0=0  The solution is the X2 array.  For visual 
verification, a pink arrow is plotted when the X2 crosses the next 
bar Close AND a red arrow points the actual Cross. */

n=20; f=2;
Qn=Sum(C^2,n);Qn_1=Sum(C^2,n-1);
Sn=Sum(C,n);Sn_1=Sum(C,n-1);
Mn=Sn/n;Mn_1=Sn_1/(n-1);
Kn=(1/n)*sqrt(n*Qn-Sn^2);Kn_1=(1/(n-1))*sqrt((n-1)*Qn_1-Sn_1^2);
bb=Mn-f*Kn;bt=Mn+f*Kn;
S=Sn_1;Q=Qn_1;
A2=(n-1)*(f^2-n+1);
A1=-2*(f^2+1-n)*S;
A0=f^2*n*Q-f^2*S^2-S^2;
x1=(-A1-sqrt(A1^2-4*A2*A0))/(2*A2);
x2=(-A1+sqrt(A1^2-4*A2*A0))/(2*A2);
Plot(C,"C",1,8);
Plot(X1,"",colorBlue,1);
Plot(X2,"",colorBlue,1);Plot(bb,"BBandBot",7,1);Plot
(bt,"BBandTop",7,1);
PlotShapes(shapeUpTriangle*Cross(x2,Ref(C,1)),colorPink);
//PlotShapes(shapeUpArrow*(Cross(bb,C)),colorRed);
PlotShapes(shapeDownTriangle*Cross(Ref(C,1),x1),colorAqua);
//PlotShapes(shapeDownArrow*(Cross(C,bt)),colorBrightGreen);
Title="The next "+Name()+" Close should be "+"\n *below"+WriteVal(x2)
+" for a BBandBot Cross"+
"\n *above"+WriteVal(x1)+" for a BBandTop Cross"+
"\n  Actual Next Close = "+WriteIf(Cum(1)!=LastValue(Cum(1)),WriteVal
(Ref(C,1)),"?");


Regards,

Pal





--- In amibroker@xxxxxxxxxxxxxxx, "Gary A. Serkhoshian" 
<serkhoshian777@xxxx> wrote:
> Pal,
>  
> That makes sense as I've visually seen what you've described.  It 
seems like our primary job when interpreting the data is to determine 
where the critical inflection points are versus noise.
>  
> I've worked with Bollinger Bands and the net positions of the three 
groups, but am interested in how Z-Score differs from what a 
Bollinger Band plots, and does it give a better sense of the 
inflection point we seek.
>  
> In addition, should any changes be made to the ZScore code as 
listed below for non-normal distribution as you describe COT data to 
be?  How do you determine if the data is normally distributed?
>  
> Sorry for all the questions, but you've piqued my interest, and 
you've been very clear in your explainations.
>  
> I'd be happy to code any adjustments based on your suggestions, and 
post them on the board.
>  
> Code Below
>  
> Kind Regards,
> Gary
>  
> 
> /*
> 
> 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.
> 
> Note that most of the Closes (95 percent, on average) will have 
ZScore
> 
> values between -2.0 and +2.0.
> 
> */
> 
> // 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);
> 
> /* 
> 
> Version 2
> 
> normal percentile to Z Score conversion 
> 
> Schmeiser (1979) came up with the following simple formula for p > 
0.5:
> 
> z = {p ^ 0.135 - (1-p) ^ 0.135} / 0.1975
> 
> According to a table in Shore (1982), it is accurate to two digits 
at p = 0, 0.4, 0.8, ..., 
> 
> which may be good enough.
> 
> */
> 
> //p = 0.025;
> 
> p = Param("p", 0.025, 0.0001, 0.9999, 0.0001 );
> 
> pp = IIf(p>=0.5, p, 1.0-p);
> 
> z = ((pp ^ 0.135) - ((1.0-pp) ^ 0.135)) / 0.1975;
> 
> z = IIf(p>=0.5, z, -z);
> 
> //----------------------
> 
>  
>  
>  
>  
> 
> 
> palsanand <palsanand@xxxx> wrote:
> Gary,
> 
> If you plot the Net Longs of all the 3 players (Commercials, Large 
> speculators and Small traders), you will see that the plot of the 
> Commercials and Large speculators are at opposite sides about the 
> mean (most of the time) and the small traders closer to the mean.
> 
> You will see that the plot of the Commercials and Large speculators 
> are either diverging from each other or going parallel (most of the 
> time).
> 
> You can then watch for trend-change pullbacks or breakout signals 
at 
> the specific time on the plot where the Commercials and Large 
> Speculators begin converging from their extreme positions (visually 
> identified) on either side of the mean.  
> 
> You may use Z-Scores to identify the extreme positions.  Z-Scores 
> tend to be used mainly in the context of the normal curve, and 
their 
> interpretation based on the standard normal table. It would be 
> erroneous to conclude, however, that Z-Scores are limited to 
> distributions that approximate the normal curve. Non-normal 
> distributions can also be transformed into sets of Z-Scores. In 
this 
> case the standard normal table cannot be consulted, since the shape 
> of the distribution of Z-Scores is the same as that for the 
original 
> non-normal distribution. For instance, if the original distribution 
> is positively skewed the distribution of Z-Scores also will be 
> positively skewed.
> 
> Regardless of the shape of the distribution, the shift to Z-Scores 
> always produces a distribution with a mean of 0 and a variance of 1.
> 
> Regards,
> 
> Pal
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "Gary A. Serkhoshian" 
> <serkhoshian777@xxxx> wrote:
> > Pal,
> >  
> > Thanks for the post as I've been racking my brain thinking of 
ways 
> to trade COT.  Could you please elaborate on your statement below.  
> Specifically, how are you identifying extremes (std dev?), and when 
> you write "low points and turning up" are you referring to the net 
> commercial position.  Taking it a step further, can I assume you 
mean 
> net-short commerical?
> >  
> > Thanks,
> > Gary
> >  
> > So, for those places where the 
> > Commercials are at extreme low points and turning up, and the 
Large 
> > speculators are at the opposite extreme and turning down, the 
> market 
> > will probably turn down shortly (vice-versa for an upside move).  
> The 
> > small speculators are usually trading with the primary trend.
> > 
> > 
> > 
> > 
> > ---------------------------------
> > Do you Yahoo!?
> > Yahoo! SiteBuilder - Free, easy-to-use web site design software
> 
> 
> Yahoo! Groups SponsorADVERTISEMENT
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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 the Yahoo! Terms of 
Service. 
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design software


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/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/