```
declare upper;
input showlabel=yes;
input showHiLoLines = yes; #plots res and support lines
input showbubble = yes; #plots hi/lo
input showZigZaglines = yes; #plots zigzaglines
input pricelow = low;
Def swinghigh = if high > high[1] and high > high[2] and high > high[-1] and high > high[-2] then 1 else 0;
Plot swing_hi = if swinghigh then high else double.nan;
swing_hi.setstyle(curve.points);
swing_hi.SetLineWeight(2);
swing_hi.SetDefaultColor(Color.red);
Def swinglow = if low < low[1] and low < low[2] and low < low[-1] and low < low[-2] then 1 else 0;
plot swing_lo = if swinglow then low else double.nan;
swing_lo.setstyle(curve.points);
swing_lo.SetLineWeight(2);
swing_lo.SetDefaultColor(Color.lime);
#plot swing high and swing low lines
def Hi = if !isNaN(swing_hi) then high else Hi[1];
def Lo = if !isNaN(swing_lo) then low else Lo[1];
plot R1 = if showHiLoLines then Hi else double.NaN;
plot S1 = if showHiLoLines then Lo else double.NaN;
R1.SetPaintingStrategy(PaintingStrategy.DASHES);
S1.setPaintingStrategy(paintingStrategy.DASHES);
R1.setDefaultColor(color.red);
s1.setDefaultColor(color.lime);
### plots zigzaglines
plot zigzag = if showZigZaglines and swinghigh then high else if showZigZaglines and swinglow then low else double.NaN;
zigzag.enableApproximation();
zigzag.SetPaintingStrategy(PaintingStrategy.line);
zigzag.setLineWeight(1);
zigzag.setDefaultColor(color.white);
addChartBubble(showbubble,swing_hi,if hi > lo and hi > hi[1] then "HH" else "LH",color.white,yes);
addChartBubble(showbubble,swing_lo,if lo <hi and lo < lo[1] then "LL" else "HL",color.white,yes);
plot value1 = if swing_lo and Lo < Hi and Lo > Lo[1] then pricelow else Double.NaN;
value1.SetPaintingStrategy(PaintingStrategy.VALUES_below);
value1.SetDefaultColor(Color.WHITE);
```