Contribute an indicator to the library by clicking here. Note you must be logged in.

New! Stock Portfolio Organizer is now available:
  • Shares, Margin, Futures and Forex
  • EOD and Realtime data
  • And Much More...
GoTo Stock Portfolio Organizer
New! WiseTrader Toolbox for Amibroker is now available with:
  • Advanced Adaptive Indicators
  • Advanced Pattern Exploration
  • Neural Networks
  • And Much More...
GoTo WiseTrader Toolbox

Popular Indicators

Double Top and Bottom Detection for Amibroker (AFL)

2 / 5 (Votes 6)

writing “Top and Bottom” you can view at the wall chart.
hopefully usefull.


Here is a screenshot of how the indicator looks:

Similar Formulas



Dear sir, am using AMI-5, the double top-double bottom afl not working in my system AMI-5 not supporting ?? am not know..pls help me… S.SURESH…98424 06366.

2. Alok

Even this AFL is not showing any top or bot in the chart it is blank, ami 5.30

3. isfandi

Sir.. pls u put the price firsly or u grab this afl into price chart. no prob with Ami 5.3

4. Alok

Dear Isfandi,

I did exactly as you said, still does not display anything. using AMi 5.3,

5. Anthony

My suggestion change your back ground with black color, so you can see it because the words in White and Yellow color. And don’t forget drag the price first. Have a nice day!

6. isfandi

Dear Alok,

I have been change the writing color, if u use background with white color try this a part of formula (copy and paste to similar paragraf), dont forget put the price firstly and try for some stock pic until u find it.

Buy = doublebot; 
Sell = doubletop; 
for( i = 0; i < BarCount; i++ ) 
if( Buy[i] ) PlotText( "BOT " , i, L[ i ],colorBlue ); 
if( Sell[i] ) PlotText( "TOP" , i, H[ i ], colorRed ); 


8. gopal


Yes. None of us are able to see this indicator.
Also, the indicator says to look for green and red arrows.But, there is no code for plotting these arrows.

Request you to please post the working formula of this indicator once again for everyone’s benefit.


9. isfandi

Ok, hope not everyone get same problem, I dont know why can’t show wheres no prob with me, am using 5.3 too

try one’s more:

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

_SECTION_BEGIN("Detecting double tops and bottoms");
/* Detecting double tops and bottoms (come into view, by Isfandi)*/ 
percdiff = 5; /* peak detection threshold */ 
fwdcheck = 5; /* forward validity check */ 
mindistance = 10; 
validdiff = percdiff/400; 

PK= Peak( H, percdiff, 1 ) == High; 
TR= Trough( L, percdiff, 1 ) == Low; 

x = Cum( 1 ); 
XPK1 = ValueWhen( PK, x, 1 ); 
XPK2 = ValueWhen( PK, x, 2 ); 
xTR1 = ValueWhen( Tr, x, 1 ); 
xTr2 = ValueWhen( Tr, x, 2 ); 

peakdiff = ValueWhen( PK, H, 1 )/ValueWhen( PK, H, 2 ); 
Troughdiff=ValueWhen( tr, L, 1 )/ValueWhen( tr, L, 2 ); 

doubletop = PK AND abs( peakdiff - 1 ) < validdiff AND (Xpk1 -Xpk2)>mindistance AND High > HHV( Ref( H, fwdcheck ), fwdcheck - 1 ); 
doubleBot=tr AND abs( troughdiff - 1 ) < validdiff AND (Xtr1 -Xtr2)>mindistance AND Low < LLV( Ref( L, fwdcheck ), fwdcheck - 1 ); 

Buy = doublebot; 
Sell = doubletop; 
for( i = 0; i < BarCount; i++ ) 
if( Buy[i] ) PlotText( "BOT " , i, L[ i ],colorBlue ); 
if( Sell[i] ) PlotText( "TOP" , i, H[ i ], colorRed ); 

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() ); 

WriteIf(Lowest( doublebot)==1,"AmiBroker has detected some possible double 
bottom patterns for " + Name() + "\nLook for red arrows on the price 
chart.", "There are no double bottom patterns for " + Name() ); 
10. isfandi

Please check afl not different, I dont know not show maybe plugins problem.

Ok, I will contribute some plugins with new title “Sharing Plugins” hope finish this problem.

11. isfandi

sorry can not post zip file here, pls moderator help us



I checked it and it works fine it doesn’t need any plugins. It certainly doesn’t work very well but it works sometimes.

sir pls help me this afl is not work on ami 5.30

14. roneen

yeah it is working with 5.3

not working.

i am Amibroker 5.4 ,when i inser code its come blank.

it works monthly chart

Please login here to leave a comment.

Main Menu