Dear Editor,

Regarding the Metastock formula for the TPR appeared in my March 2004 article on "Mechanically Recognizing Triangular Formations" I got several e-mails from S&C readers reporting that the formula didn't function. I must say that the formula is correct, but yes it may produce no results if the configuration of the software is not appropriate for the TPR. Users of software other than Metastock may experience the same problem.

In order to reduce the scanning time of huge databases, most software calculate the scanning filter using minimum data records for each equity. For example,to calculate a 5-day simple moving average of today most software usually load only the last 5 days of the price data. The TPR as stated in my article needs many historical price records to produce results so the software must be configured and forced to load many price data for each equity.

Metastock users may go to the Metastock Explorer Options menu and uncheck the "load minimum records" option. Also, from the same menu, they must force Metastock to load many price records (1000 or more, for example) for each equity before the filtering process. Users of other software may do similar configuration.

Regards,
Giorgos Siligardos

METASTOCK CODE FOR TPR EXPLORATIONS
-----------------------------
Use the code below as a filter to identify TFs that last up to 60 
trading days and produce retracements of no more than 50%. In 
column A, write exactly the same code, but in the last line 
substitute "TPR>0" with "TPR." You may also name column A as "TPR." 
The code works with daily charts and requires the zz(20%) to have 
produced at least four swings in chart history to function properly.
-----------------------------

{Main}
zz:=Zig(C,20,%);
x:=Min(BarsSince(zz>Ref(zz,-1) AND Ref(zz,-1)< Ref(zz,-2)),BarsSince(zz< Ref(zz,-1) AND Ref(zz,-1)>Ref(zz,-2)));
I:=LastValue(x)+1;
xM:=LastValue(I/2);
A:=LastValue(LinRegSlope(C,I));
{regression line}
reg:= A*x+LastValue(LinearReg(C,I))-A*(I-1);
{Up And Down Indicators}
day1:=LastValue(ValueWhen(1,x=0,DayOfMonth()));
Month1:=LastValue(ValueWhen(1,x=0,Month()));
year1:=LastValue(ValueWhen(1,x=0,Year()));
OK:=BarsSince(day1=DayOfMonth() AND month1=Month() AND year1=Year())>=0;
down:=If(OK=False,0,If(Min(C-reg,0)=0,PREV,Min(C-reg,0)));
up:=If(OK=False,0,If(Max(C-reg,0)=0,PREV,Max(C-reg,0)));
{Slope of up and down indicators}
Id:=LastValue(Cum(Alert(OK AND C< reg,I)));
Iu:=LastValue(Cum(Alert(OK AND C>reg,I)));
downSlope:=Sum((x-xM)*(down-LastValue(Sum(down,Id)/Id)),Id)/Sum((x-xM)*(x-xM),Id);
upSlope:=Sum((x-xM)*(up-LastValue(Sum(up,Iu)/Iu)),Iu)/Sum((x-xM)*(x-xM),Iu);
{Short Term Swings}
SS:=Sum(If(Cross(Mov(C,5,S),reg),1,0)+If(Cross(reg,Mov(C,5,S)),1,0),I-1);
{Max Retracement}
retr:=Max(Abs(C-HHV(C,I+1)),Abs(C-LLV(C,I+1)))
/Abs(ValueWhen(2,x=0,C)-ValueWhen(1,x=0,C))*100;
{Volume slope}
VolSlope:=Sum((x-xM)*(V-LastValue(Sum(V,I)/I)),I)/Sum((x-xM)*(x-xM),I);
{TPR Formula}
TPR:=
If(I>=10 AND I<=60 AND downSlope>0 AND upSlope<0 AND retr<50 AND SS>=3,
{Time}
If(I>=15 AND I<30,2,0) +
If(I>=30 AND I<=55,1,0) +
{r^2}
If(RSquared(C,I)<0.2,2,0) +
If(RSquared(C,I)>=0.2 AND RSquared(C,I)<0.5,1,0) +
{Max retracement}
If(retr<20,4,0) +
If(retr>=20 AND retr<38,3,0) +
{Volume}
If(VolSlope<0,4,0)+1,0);
TPR>0

-Giorgos Siligardos, Ph.D.