Asish, Darsh
Please do note that the code uses the zig function which tends to look forward. But this is for only visual presentation and hence should not be problem. By the way my "Mabiuts" also uses the zig function to check for the break of the previous high and it seems to work quite fine.
Following is the code snippet for Ami. Paste in any chart afl and you will get the pivot plots. Please note these is a parameter called "Change %" which may have to be adjusted depending on the stock as we have high and low volatility stocks.
Q=Param("% Change",2,1,10,1);
Z= Zig(C ,q ) ;
HH=((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(z,q,1 ) >Peak(Z,q,2)));
LH=((Z<Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)) AND (Peak(Z,q,1 ) <Peak(Z,q,2)));
HL=((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) >Trough(Z,q,2)));
LL=((Z>Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2)) AND (Trough(Z,q,1 ) <Trough(Z,q,2)));
GraphXSpace = 5;
dist = 0.5*ATR(20);
for( i = 0; i < BarCount; i++ )
{
if( HH ) PlotText( "HH", i, H[ i ]+dist, colorYellow );
if( LH ) PlotText( "LH", i, H[ i ]+dist, colorYellow );
if( HL ) PlotText( "HL", i, L[ i ]-dist, colorPink );
if( LL ) PlotText( "LL", i, L[ i ]-dist, colorPink );
}