// Downloaded From https://www.WiseStockTrader.com _SECTION_BEGIN("Trading_Trendline_Breaks"); zz0 = Zig( Close, 7 ); zz1 = Ref( zz0, -1 ); zz2 = Ref( zz0, -2 ); tr = ValueWhen( zz0 > zz1 AND zz1 < zz2, zz1 ); pk = ValueWhen( zz0 < zz1 AND zz1 > zz2, zz1 ); PU = tr + abs( tr ) * 0.05; PD = pk - abs( pk ) * 0.05; res = IIf( Close >= PU AND zz0 > zz1, 1, IIf( Close <= PD AND zz0 < zz1, -1, 0 ) ); res = ValueWhen( res != 0, res ); Buy = res == 1 AND Ref( res, -1 ) == -1; Sell = res == -1 AND Ref( res, -1 ) == 1; Short = Sell; Cover = Buy; Plot( zz0, "ZigZag", colorBlue, styleThick ); Plot( Close, "Price", colorBlack, styleBar ); //PlotShapes( Buy * shapeUpArrow, colorGreen, 0, L, -60 ); //PlotShapes( Sell * shapeDownArrow, colorRed, 0, H, -60 ); PlotShapes( Buy * shapeUpArrow, colorGreen ); PlotShapes( Sell * shapeDownArrow, colorRed); Plot( Flip( Buy, Sell ), "Trade", colorPaleGreen, styleArea | styleOwnScale, 0, 1 ); _SECTION_END();