Isolated Pivots
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © patrickws

//@version=5
indicator("Isolated Pivots", overlay=true)

pivotHigh() =>
    (high[1] > math.max(high[2], high[0])) and (low[1] > math.max(low[2], low[0]))
    
pivotLow() => 
    (low[1] < math.min(low[2], low[0])) and (high[1] < math.min(high[2], high[0]))
        

plotshape(pivotHigh(), text = "H", style = shape.labeldown, location = location.abovebar, color = color.red, textcolor = color.white, offset=-1)
plotshape(pivotLow(), text = "L", style = shape.labelup, location = location.belowbar, color = color.green, textcolor = color.white, offset=-1)