Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
Find Out More Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Double Top and Bottom Detection for Amibroker (AFL)

Rating:
2 / 5 (Votes 6)
Tags:
amibroker, exploration, pattern

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

Isfandi
Indonesia

Screenshots

Similar Indicators / Formulas

Butterfly Pattern
Submitted by asdaf1 almost 8 years ago
Double Top Detection
Submitted by sougatab about 7 years ago
Pennant Chart Pattern Exploration
Submitted by kaiji about 8 years ago
Head & Shouders
Submitted by pvsy over 7 years ago
Harmonic pattern detection
Submitted by Yaaad over 7 years ago
Candlestick Pattern Finder
Submitted by theone3000 over 7 years ago

Indicator / Formula

Copy & Paste Friendly
_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 ],colorYellow ); 
if( Sell[i] ) PlotText( "TOP" , i, H[ i ], colorWhite ); 
} 


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

17 comments

1. tigernifty

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 ); 
} 
7. vaenu999

IT NOT SHOWN IN AMI 5.

8. gopal

Hi,

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.

Thanks,
Gopal

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:

_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_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_END();

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

thanks,
Isfandi

12. administrator

Hello

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

13. rmlalitkumar

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

14. roneen

yeah it is working with 5.3

15. gajananprofits@yahoo.co.in

not working.

16. karthi_nkkkkl

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

17. Muralikrishna

it works monthly chart

Leave Comment

Please login here to leave a comment.

Back