Hi friends,
Following afl detected double top & bottom on daily closing basis. I want to
use it intraday. So, pl, modify this afl for said purpose.
Thanks
/* Detecting double tops and bottoms*/
//Graph0=Close;//
Plot(C,"close",colorBlack,styleCandle);
ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume:
"+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
SetChartBkColor(ParamColor("BK",colorDarkGrey));
//Graph1= Zig( Close, 5 );
percdiff = 5; /* peak detection threshold */
fwdcheck = 5; /* forward validity check */
mindistance = 10;
validdiff = percdiff/10;
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 );
Sell = doubletop;
Buy = doubleBot;
shape = Buy * shapeUpArrow + Sell * shapeDownArrow;
PlotShapes( shape, IIf( Buy, colorGold, colorGold ), C );