MetaStock exploration for system to detect flag and pennant patterns
Column A
Name: Price
Formula: C
Column B
Name: Pole Top
Formula:
zz:=Zig(C,17,%);
X:=BarsSince(ZZ < Ref(ZZ,-1)AND Ref(ZZ,-1) > Ref(ZZ,-2));
X1:=LastValue(X)+1;
c2:=Ref(HHV(C,(2+X1)),-1);C2
Column C
Name: Pole Bot
Formula:
zz:=Zig(C,17,%);
X:=BarsSince(ZZ < Ref(ZZ,-1)AND Ref(ZZ,-1) > Ref(ZZ,-2));
X1:=LastValue(X)+1;
C3:=Ref(LLV(C,26),-X1);C3
Column D
Name: Pole %
Formula:
zz:=Zig(C,17,%);
X:=BarsSince(ZZ < Ref(ZZ,-1)AND Ref(ZZ,-1) > Ref(ZZ,-2));
X1:=LastValue(X)+1;
c2:=Ref(HHV(C,(2+X1)),-1);
c3:=Ref(LLV(C,26),-X1);
POLE:=(C2-C3)/C3*100;POLE
Column E
Name: Target %
Formula:
zz:=Zig(C,17,%);
X:=BarsSince(ZZ < Ref(ZZ,-1)AND Ref(ZZ,-1) > Ref(ZZ,-2));
X1:=LastValue(X)+1;
c2:=Ref(HHV(C,(2+X1)),-1);
c3:=Ref(LLV(C,26),-X1);
POLE:=(C2-C3)/C3*100;
TARGET:=1.94* Power(pole ,.724);TARGET
Column F
Name: Target Price
Formula:
zz:=Zig(C,17,%);
X:=BarsSince(ZZ < Ref(ZZ,-1)AND Ref(ZZ,-1) > Ref(ZZ,-2));
X1:=LastValue(X)+1;
c2:=Ref(HHV(C,(2+X1)),-1);
c3:=Ref(LLV(C,26),-X1);
POLE:=(C2-C3)/C3*100;
TARGET:=1.94* Power(pole ,.724); (1+TARGET/100)*C
Filter
Column A is the prebreakout price, column B is the highest point on the flag pole, column C is the pole base, column D is the % pole height, column E is the target % profit, and column F shows the target price. All prices are on a closing basis. Columns B-F are not essential for running the exploration, but they will help to calculate your exit price target.