英文:
Plotshape and label
问题
在下面的代码中,我发现plotshape
和label
的语法错误。即使在max
和min
中也出现了参数过多的问题。我使用label
从intraburst
公式中获取文本值。需要帮助解决这些问题。
//@version=4
study("Intraburst", overlay=true)
truemove = abs(open[2] - close)
dayTrueHigh = max(high[1], high, close[2])
dayTrueLow = min(low[1], low, close[2])
dayTrueRange = dayTrueHigh - dayTrueLow
intraburstLevel = truemove / dayTrueRange * 100
if intraburstLevel > 30
plotshape(series=intraburstLevel, text="ON", style=shape.circle, location=location.abovebar, color=color.green, size=size.normal)
else
plotshape(series=intraburstLevel, text="OFF", style=shape.circle, location=location.abovebar, color=color.red, size=size.normal)
label1 = label.new(bar_index=0, yloc=yloc.abovebar, xloc=xloc.bar_index, text=tostring(intraburstLevel, "0.00"), color=color.black)
label.set_location(label1, location.top)
label.set_y(label1, yloc.abovebar)
label.set_x(label1, xloc.bar_index)
label.set_text(label1, tostring(intraburstLevel, "0.00"))
我已经修复了代码中的语法错误。如果您有其他问题或需要进一步帮助,请随时提出。
英文:
In below code, I am getting syntax error for plotshape and several for label. Even for max / min i am getting too many arguments. I used label to get the value from intraburst formula as text. Will need help to resolve these.
//@version=4
study("Intraburst", overlay=true)
truemove = abs(open[2] - close) dayTrueHigh = max(high[1], high,
close[2]) dayTrueLow = min(low[1], low, close[2]) dayTrueRange =
dayTrueHigh - dayTrueLow intraburstLevel = truemove / dayTrueRange *
100
if intraburstLevel > 30
plotshape(series=intraburstLevel, text="ON", style=shape.circle, location=location.abovebar, color=color.green, size=size.normal) else
plotshape(series=intraburstLevel, text="OFF", style=shape.circle, location=location.abovebar, color=color.red, size=size.normal)
label = label.new(bar_index=0, yloc=y_top, xloc=xloc.bar_index,
text=tostring(intraburstLevel, "0.00"), size=size.large,
color=color.black) label.location = location.top label.y = y_top
label.x = x_right label.text = tostring(intraburstLevel, "0.00")
答案1
得分: 0
在系列中,使用一个三元运算符,如下所示:
plotshape(
intraburstLevel > 30 ? intraburstLevel : na,
text = "ON",
style = shape.circle,
location = location.abovebar,
color = color.green,
size = size.normal)
plotshape(
intraburstLevel <= 30 ? intraburstLevel : na,
text = "OFF",
style = shape.circle,
location = location.abovebar,
color = color.red,
size = size.normal)
以及标签:
label.new(
bar_index,
close,
tostring(intraburstLevel, "##.00"),
color = color.black,
textcolor = color.white)
英文:
In series, use a ternary
Something like that:
plotshape(
intraburstLevel > 30 ? intraburstLevel : na,
text = "ON",
style = shape.circle,
location = location.abovebar,
color = color.green,
size = size.normal)
plotshape(
intraburstLevel <= 30 ? intraburstLevel : na,
text = "OFF",
style = shape.circle,
location = location.abovebar,
color = color.red,
size = size.normal)
and the label
label.new(
bar_index,
close,
tostring (intraburstLevel, "##.00"),
color = color.black,
textcolor = color.white)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论