Plotshape and label

huangapple go评论57阅读模式
英文:

Plotshape and label

问题

在下面的代码中,我发现plotshapelabel的语法错误。即使在maxmin中也出现了参数过多的问题。我使用labelintraburst公式中获取文本值。需要帮助解决这些问题。

//@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 &gt; 30 ? intraburstLevel : na,
  text = &quot;ON&quot;,
  style = shape.circle,
  location = location.abovebar,
  color = color.green,
  size = size.normal)
plotshape(
  intraburstLevel &lt;= 30 ? intraburstLevel : na,
  text = &quot;OFF&quot;,
  style = shape.circle,
  location = location.abovebar,
  color      = color.red,
  size = size.normal)

and the label

label.new(
  bar_index,
  close,
  tostring (intraburstLevel, &quot;##.00&quot;),
  color     = color.black,
  textcolor = color.white)

huangapple
  • 本文由 发表于 2023年2月9日 02:07:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390006.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定