【发布时间】:2019-09-22 05:58:21
【问题描述】:
编辑以包含我想要的图片。
the long arrows show where the labels should be
我的 label.new 代码没有按照我想要的方式运行,即打印高于/低于阻力位/支撑位的标签。
我试过了
label.new(bar_index, top1, tostring(top1), xloc=xloc.bar_index, yloc=yloc.price, style=label.style_labeldown, color=color.red, size=size.small)
但是那个 xloc 是不对的,当它编译时,它会显示当前蜡烛上的所有标签。
study(title="srlabel", overlay=true)
//code from [RS] support and resistance indicator
window1 = input(title='lookback window 1', type=input.integer, defval=8)
window2 = input(title='lookback window 2', type=input.integer, defval=21)
top1 = valuewhen(high >= highest(high, window1), high, 0)
bot1 = valuewhen(low <= lowest(low, window1), low, 0)
top2 = valuewhen(high >= highest(high, window2), high, 0)
bot2 = valuewhen(low <= lowest(low, window2), low, 0)
//this is what I've added to show the price of the s/r levels
label.new(bar_index, top1, tostring(top1), xloc=xloc.bar_index, yloc=yloc.price, style=label.style_labeldown, color=color.red, size=size.small)
label.new(bar_index, bot1, tostring(bot1), xloc=xloc.bar_index, yloc=yloc.price, style=label.style_labelup, color=color.blue, size=size.small)
//plots
t1 = plot(top1, color=top1 != top1[1] ? na : color.red, linewidth=1, title="")
b1 = plot(bot1, color=bot1 != bot1[1] ? na : color.blue, linewidth=1, title="")
t2 = plot(top2, color=top2 != top2[1] ? na : color.red, linewidth=1, title="")
b2 = plot(bot2, color=bot2 != bot2[1] ? na : color.blue, linewidth=1, title="")
fill(t1, t2, transp=80, color=color.red, title="")
fill(b1, b2, transp=80, color=color.blue, title="")
我想在各自的价格蜡烛上方和下方显示标签。我认为解决方案都取决于该 xloc 规范。
任何想法将不胜感激。
【问题讨论】:
标签: plot pine-script