我试图让整个背景颜色在一个条件下(例如绿色),如果最后一个关闭是在关闭50条以上,背面和红色,如果它在下面。
我尝试过不同的方法,我可以改变颜色,但它不会最终着色整个背景,但只有特定的区域。
我的剧本:
bgcolor(close[50] >= open[1] ? color.red : color.green, transp=70)在这种情况下,整个背景应该是红色的,因为最后一次关闭是在关闭50巴以下(用黄色标签表示)。
对我需要改变的东西有什么想法吗?
发布于 2020-04-11 07:47:12
这将在你的情况下为背景着色。它使用一条非常宽的线来做这件事,因为指示器占据了所有的背景,所以一些像测量工具这样的图表功能不能和Shift-Click一起使用,但是如果你明确地选择它的工具,它就会工作。
如果你不想让它覆盖整个图表,你可以播放背景的位置和宽度。
背景很轻。如果要更改其亮度,则需要在两个color.new()调用中使用透明度,因为它不能从输入中控制:
//@version=4
study("", "", true)
offsetCalc = input(50, "Close lookback", minval = 2)
offstBg = input(100, "Background: Horizontal Offset to its Center", minval = 0, step = 5)
lineWidth = input(10000, "Background: Width", minval = 0, step = 100)
condUp = barstate.islast and close[1] > close[offsetCalc]
condDn = barstate.islast and close[1] < close[offsetCalc]
c_lineColor = condUp ? color.new(color.green, 97) : condDn ? color.new(color.maroon, 97) : na
if barstate.islast
var line bg = na
line.delete(bg)
bg := line.new(bar_index[offstBg], low - tr, bar_index[offstBg], high + tr, color = c_lineColor, extend = extend.both, width = lineWidth)https://stackoverflow.com/questions/61110568
复制相似问题