# afl for consolidation breakout.

#### 1sandeepgupta

##### Well-Known Member
Dear sir,please provide me afl explorations for consolidation breakout downside,consolidation breakout upside, consolidation over 16 weeks like provided in metastock on guppytraders.com in exploration section.Thank you.

#### 1sandeepgupta

##### Well-Known Member
Metastock code for consolidation breakout is

Congestion Index
((HHV(C,80)-LLV(C,80))/LLV(C,80))*100

Consolidation Breakout Upside
If(Ref(Fml("Congestion Index"),-5),<,10,
{and} If(Fml("Congestion Index"),>=,10,
{and} If(CLOSE,>,Ref(HHV(C,80),-5),
{and} If(Mov(V,5,S),>=,1.5*(Ref(Mov(V,60,S),-5)),+1,0),0),0),0)

Consolidation Breakout Downside
If(Ref(Fml("Congestion Index"),-5),<,10{%},
{and} If(Fml("Congestion Index"),>=,10{%},
{and} If(CLOSE,<,Ref(LLV(C,80),-5),
{and} If(Mov(V,5,S),>=,1.5*(Ref(Mov(V,60,S),-5)),+1,0),0),0),0)

Last edited:

#### 1sandeepgupta

##### Well-Known Member
hi actually I wrote two afl on the basis of the above two as fellows-

//Consolidation Breakout Upside
CongestionIndex = ((HHV(C,80)-LLV(C,80))/LLV(C,80))*100;
Filter= (Ref(CongestionIndex,-5)< 10) AND (CongestionIndex >= 10) AND (Close > Ref(HHV(C,80),-5)) AND (MA(V,5) >= 1.5*(Ref(MA(V,60),-5)));

//Consolidation Breakout Downside
CongestionIndex = ((HHV(C,40)-LLV(C,40))/LLV(C,40))*100;
Filter= (Ref(CongestionIndex,-5)< 10) AND (CongestionIndex >= 10) AND (Close < Ref(LLV(C,40),-5)) AND (MA(V,5) >= 1.5*(Ref(MA(V,60),-5)));

#### 1sandeepgupta

##### Well-Known Member
plz covert this for amibroker
The new version of the above two afls in one, enjoy.
//20 is for one month consolidation,replace it for 40 for two month etc.5 is the range breadth in percentage, you can replace it for 10,if you need wider range .
CongestionIndex = ((HHV(C,20)-LLV(C,20))/LLV(C,20))*100;
//Consolidation Breakout Upside
up= (Ref(CongestionIndex,-5)< 5) AND (CongestionIndex >= 5) AND (Close > Ref(HHV(C,20),-5)) AND (MA(V,5) >= 1.5*(Ref(MA(V,60),-5)));
//Consolidation Breakout Downside
dn= (Ref(CongestionIndex,-5)< 5) AND (CongestionIndex >= 5) AND (Close < Ref(LLV(C,20),-5)) AND (MA(V,5) >= 1.5*(Ref(MA(V,60),-5)));
//Exploration for break out either upside or downside
Filter=up OR dn;

#### deep_pocket

##### New Member
Yes this my first time. thank you.

#### sumitalwar

##### Active Member
Can anyone have plot feature shading the relevant consolidation area to see on the chart

#### amitrandive

##### Well-Known Member
Can anyone have plot feature shading the relevant consolidation area to see on the chart
Code:
``````//20 is for one month consolidation,replace it for 40 for two month etc.5 is the range breadth in percentage, you can replace it for 10,if you need wider range .
CongestionIndex = ((HHV(C,20)-LLV(C,20))/LLV(C,20))*100;
//Consolidation Breakout Upside
up= (Ref(CongestionIndex,-5)< 5) AND (CongestionIndex >= 5) AND (Close > Ref(HHV(C,20),-5)) AND (MA(V,5) >= 1.5*(Ref(MA(V,60),-5)));
//Consolidation Breakout Downside
dn= (Ref(CongestionIndex,-5)< 5) AND (CongestionIndex >= 5) AND (Close < Ref(LLV(C,20),-5)) AND (MA(V,5) >= 1.5*(Ref(MA(V,60),-5)));
//Exploration for break out either upside or downside
Filter=up OR dn;