//@version=5
indicator(title="枢轴高点与低点", shorttitle="枢轴点")
lengthL = input.int(11, title="左侧长度", minval=1)
lengthR = input.int(11, title="右侧长度", minval=1)
pivotH = ta.pivothigh(lengthL, lengthR)
pivotL = ta.pivotlow(lengthL, lengthR)
bgcolor(color = bool(pivotH) ? color.new(color.red, 70)
: bool(pivotL) ? color.new(color.green, 70) : na,
offset = -lengthR)
plotshape(pivotH, offset = 0-lengthL,
text = "卖出", textcolor = color.red,
style = shape.arrowdown, color=color.new(color.red, 0),
size = size.auto, location = location.abovebar)
plotshape(pivotL, offset = 0-lengthL,
text = "买入", textcolor = color.lime,
style = shape.arrowup, color=color.new(color.lime, 0),
size = size.auto, location = location.belowbar)