Carl,
You might want to have a look at this code, supplied by Thomas Janeczko in the AFL library. It is for Double Tops, but you can modify it for the double bottoms. Look at the function reference for PEAK, TROUGHS and ZIGZAG also. Tom /* Detecting double tops */ percdiff = 3; /* peak detection threshold */ fwdcheck = 5; /* forward validity check */ mindistance = 5; validdiff = percdiff/400; PK= Peak( H, percdiff, 1 ) == High; x = Cum( 1 ); XPK1 = ValueWhen( PK, x, 1 ); XPK2 = ValueWhen( PK, x, 2 ); peakdiff = ValueWhen( PK, H, 1 )/ValueWhen( PK, H, 2 ); doubletop = PK AND abs( peakdiff - 1 ) < validdiff AND (XPK1 - XPK2)>mindistance AND High > HHV( Ref( H, fwdcheck ), fwdcheck - 1 ); Buy = Sell = doubletop; //IIf(doubletop,PlotShapes( shapeSmallDownTriangle, colorGreen, 5 ),""); PlotShapes( IIf( Buy, shapeDigit9 + shapePositionAbove, shapeNone ), colorAqua ); //GraphXSpace = 5; WriteIf( Highest( doubletop ) == 1, "AmiBroker has detected some possible double top patterns for " + Name() + "\nLook for green arrows on the price chart.", "There are no double top patterns for " + Name() ); From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Carl Vanhaes Sent: Thursday, September 25, 2008 8:37 AM To: [email protected] Subject: [amibroker] Help coding double bottom Hi, I am still a newbie switching from easylanguage to AFL and am trying to plot double bottoms that are separated only by a few bars. Something must be wrong with my coding below because no signal is generated despite I can see those patterns on the charts. Basically the idea is: Price tries to break down a recent low but fails and rebounds on or just after the breakdown bar (think it is sometimes called a Vic2B pattern). Can you please help me correct this code: Condition1= Low = LLV(L,25); Condition2= Ref(Sum(Condition1,7),-1)==0 AND Ref(Sum(Condition1,13),- 1)>0 AND Cross(Ref(ValueWhen(Condition1, L, 1),-1),L); Condition3= (Cross(C, ValueWhen(Condition2, H, 1))) AND (ValueWhen (Condition2,L,1) == LLV(L,30)); PlotShapes( IIf( Condition5, shapeUpArrow, shapeNone ), colorGreen ); Filter = Condition5 OR Condition6; AddTextColumn(FullName(), "Company Name"); AddColumn(Condition5, "Dble_bot", 1); AddColumn(C, "Close", 1.3); Thank you in advance, Carl
