//@version=6 indicator("Workshop 05 Swing Diary", overlay=true) wing = input.int(2, "Bars on each side", minval=1) peak = ta.pivothigh(high, wing, wing) valley = ta.pivotlow(low, wing, wing) newHigh = not na(peak) and barstate.isconfirmed newLow = not na(valley) and barstate.isconfirmed var float lastHigh = na var float lastLow = na if newHigh lastHigh := peak if newLow lastLow := valley plot(lastHigh, "Known high", color=color.gray, style=plot.style_stepline) plot(lastLow, "Known low", color=color.blue, style=plot.style_stepline) plotshape(newHigh, "High confirmed now", shape.circle, location.abovebar, color=color.gray, size=size.tiny) plotshape(newLow, "Low confirmed now", shape.circle, location.belowbar, color=color.blue, size=size.tiny)