繁体   English   中英

我不想用三角形显示每个枢轴高点/低点,如果我选中该框,它只显示最近的最近高点和最近的低点

[英]I want to instead of showing every Pivot High/Low with the triangle, if i check the box it show just the last recent high and recent low

showRecentOnly = input(title="Pivots Highs & Lows", defval=false)

lb = input(defval=5, title='Left Bars')
rb = input(defval=5, title='Right Bars')
 
mb = lb + rb + 1

highestbars_1 = ta.highestbars(mb)
iff_1 = highestbars_1 == -lb ? high[lb] : na
plotshape(not na(high[mb]) ? iff_1 : na, title='Triangle Pivot High', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 60), size=size.tiny, offset=-lb)

lowestbars_1 = ta.lowestbars(mb)
iff_2 = lowestbars_1 == -lb ? low[lb] : na
plotshape(not na(low[mb]) ? iff_2 : na, title='Triangle Pivot Low', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 60), size=size.tiny, offset=-lb)

如果我们只绘制最后一个高点和低点的三角形,那么当出现新的高点/低点时我们也必须删除它们,并且无法使用 pinescript 删除形状。 我们只能删除线和框等。所以在这里我做了一个版本,您可以单击复选框以显示最新枢轴高点的线并取消选中以查看以前的情况

//@version=5
indicator("test",overlay=true)
lb = input(defval=5, title='Left Bars')
rb = input(defval=5, title='Right Bars')
showlastonly=input(defval=false)
mb = lb + rb + 1

var lasthighbarindex=0
var lastlowbarindex=0
var h=0.0
var l=0.0

highestbars_1 = ta.highestbars(mb)
plotshape((not showlastonly) and (highestbars_1 == -lb), title='Triangle Pivot High', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 60), size=size.tiny, offset=-lb)
if (highestbars_1 == -lb)
    lasthighbarindex:=lb
    h:=high[lb]
else
    lasthighbarindex:=lasthighbarindex+1
lowestbars_1 = ta.lowestbars(mb)
plotshape((not showlastonly) and (lowestbars_1 == -lb), title='Triangle Pivot Low', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 60), size=size.tiny, offset=-lb)
if (lowestbars_1 == -lb)
    lastlowbarindex:=lb
    l:=low[lb]
else
    lastlowbarindex:=lastlowbarindex+1
if showlastonly and barstate.islast
    linehigh=line.new(bar_index-lasthighbarindex,h,bar_index,h,color=color.red)
    linelow=line.new(bar_index-lastlowbarindex,l,bar_index,l,color=color.green)
    line.delete(id=linehigh[1])
    line.delete(id=linelow[1])

检查前 检查

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM