Dear Mahesh,
I do not know which charting software you use but for Amibroker, Karthik had given code (based on Saint's methodology, I think) which you will have to append to your existing code. Assuming their permission, the same is given below.
_SECTION_BEGIN("Pivot Indicator");
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, colorGreen );
if( LH ) PlotText( "LH", i, H[ i ]+dist, colorRed );
if( HL ) PlotText( "HL", i, L[ i ]-dist, colorGreen );
if( LL ) PlotText( "LL", i, L[ i ]-dist, colorRed );
}
_SECTION_END();
Please note that here pivots will be marked for price change from 1% to 10% with 2% being default. When used in day trading, you will have to adjust this % change, to correctly identify the pivots. You can easily do so by editing parameters.
Sample snap of pivots detected by this code is attached for reference.
I hope this helps.
Regards,
Abhay