// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("Price1");
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();


GraphXSpace = 5;
Q = Param( "% Change", 2, 0.1, 10, 0.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 ) ) );

dist = 0.5 * ATR( 20 );

for ( i = 0; i < BarCount; i++ )
{
if ( HH[i] )
PlotText( "- -VE REVERSE", i, H[ i ] + dist[i], colorRed );

if ( LH[i] )
PlotText( "-VE REVERSE", i, H[ i ] + dist[i], colorRed );

if ( HL[i] )
PlotText( "+VE REVERSE", i, L[ i ] - dist[i], colorBrightGreen );

if ( LL[i] )
PlotText( "++ VE REVERSE", i, L[ i ] - dist[i], colorBrightGreen );
}
Filter=HH OR HL OR LH OR LL;
AddColumn(HH,"HH",1);
AddColumn(LH,"LH",1);
AddColumn(HL,"HL",1);
AddColumn (LL,"LL",1); 
Buy = HL OR LL;
Sell = HH OR LH;
SellPrice=ValueWhen(Sell,H,1);
BuyPrice=ValueWhen(Buy,L,1);
Long=Flip(Buy,Sell);
Shrt=Flip(Sell,Buy );
Plot( Flip( Buy, Sell ), "BUY", colorDarkGreen,  styleArea | styleOwnScale, 0, 20 );
Shape = (Buy * shapeSmallUpTriangle + Sell * shapeSmallDownTriangle);
PlotShapes( shape, IIf( Buy, colorYellow, colorYellow ),0, IIf( Buy, Low,High ));


//for more info visit marketlogy.com