AFL to scan for Flag or pennent patterns

#1
Hi,

can some one please help me with an afl that can scan for flag or pennent patterns.

if you can give code in metastock too that would be great.If not just amibroker is fine.

thanks for your help in advance. please please share the afl incase u have it.
 

mastermind007

Well-Known Member
#2
Hi,

can some one please help me with an afl that can scan for flag or pennent patterns.

if you can give code in metastock too that would be great.If not just amibroker is fine.

thanks for your help in advance. please please share the afl incase u have it.
There is a product named "Pattern Explorer" that does this.
 
#4
Please try this.:thumb:

PENNAT EXPLORER:-

d1max = 60;
d1min = 20;
Buy = 0;


for (d1=d1min;d1<d1max;d1++)
{
d2=4;
Hi = H;
Lo = L;
Body = ParamToggle("Use candle body rather than H & L","No|Yes", 0);

if(Body == 1)
{
Hi = Max(O,C);
Lo = Min(O,C);
}

z1=HHV(Hi,d1);
za1=HHVBars(Hi,d1);
zb1=za1-d2;
z2=HHV(Hi,zb1);
za2=HHVBars(Hi,zb1);
w1=LLV(Lo,d1);
wa1=LLVBars(Lo,d1);
wb1=wa1-d2;
w2=LLV(Lo,wb1);
wa2=LLVBars(Lo,wb1);

aa1=LastValue(Hi);
aa2=LastValue(Lo);

C3 = ParamToggle("Use a more liberal triangle shape test?", "No|Yes",0);
ExVol = ParamToggle("Exclude volume test?","No|Yes",0);

Cond1 = ((z1>=z2 AND w2>w1) OR(z1>z2 AND w2>=w1));//Allows for horizontal top or bottom
Cond2 = za1>za2 AND wa1>wa2;//Automatically satisfied if za1,za2,wa1 and wa2 all exist

//Cond3 ensures triangle shape
Cond3 =((za1>wa1 AND wa1>za2 AND za2>wa2) OR (wa1>za1 AND za1>wa2 AND wa2>za2));

if(C3 == 1)
{
Cond3 =((za1>wa1 AND wa1>za2) OR (wa1>za1 AND za1>wa2));
}

Cond4 = aa1<z2 AND aa2>w2 ;// Triangle shape continues to last Value
Cond5 = Ref(Volume,-za1) > MA(Volume,d2);

if(ExVol == 1)
{
Cond5 =1;
}

//Conditions 6 & 7 require close price trend to be up
Cond6 = Ref(MA(Close,d1),-za1) > Ref(MA(Close,d1),-2*za1) ;
Cond7= MA(Close,d1) > Ref(MA(Close,d1),-2*za1);

Buying = Cond1 AND Cond2 AND Cond3 AND Cond4 AND Cond5 AND Cond6 AND Cond7;
Buy = Buy + Buying;
}
for(i=1;i<BarCount;i++)
{
if(Buy>=1)
{
Buy[i-1]=0;
Buy = 1;
}
}

//Retain only the last of consecutive buy signals
Filter=Buy;

NumColumns = 8;
Column0 = Cond1;
Column1 = Cond2;
Column2 = Cond3;
Column3 = Cond4;
Column4 = Cond5;
Column5 = Cond6;
Column6 = Cond7;
Column7 = Buy;
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?