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

发布于 2025-02-11 07:06:28 字数 721 浏览 1 评论 0原文

showrecentonly = input(title =“枢轴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)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一桥轻雨一伞开 2025-02-18 07:06:28

如果我们要仅以最后的高和低点绘制三角形,那么当新的高/低点发生新的高/低时,我们也必须删除它们,并且不可能使用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])

If we are going to plot the triangles for only last high and low, then we will have to delete them too when new high/low occurs and it is not possible to delete shapes using pinescript. We can only delete lines and boxes etc. So here I have done a version where you can click a checkbox to show line for latest pivot high lows and uncheck to see how it was previously

//@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])

Before checking After checking

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文