代码之家  ›  专栏  ›  技术社区  ›  Jesson

为什么如果我有连续的绘图标记,标签只在第一个标记处

  •  0
  • Jesson  · 技术社区  · 2 年前

    如果有连续的绘图标记,则标签仅显示在第一个标记上。是否要更改此行为?我希望每个烛台都有2%的显示。

    plot(stopLossPrice, color=color.rgb(255, 153, 0), title="Stop Loss Mark", linewidth=2, style=plot.style_steplinebr, offset=offset)
    if (na(stopLossPrice[1]) and not na(stopLossPrice))
        label.new(bar_index, stopLossPrice, text=StopLoseText, style=label.style_label_up, color=color.new(#00f708, 100), textcolor=color.rgb(255, 153, 0), size=size.small)
    

    enter image description here

    如果标签是连续打印标记,则仅在第一个标记处显示标签。

    1 回复  |  直到 2 年前
        1
  •  1
  •   vitruvius    2 年前

    您正在使用一个条件( (na(stopLossPrice[1]) and not na(stopLossPrice)) )以创建标签。

    stopLossPrice 你正在策划的价格。通过查看图像,一旦开始绘制, na(stopLossPrice[1] 将不再是 true 。因此,您将不会获得下一支蜡烛的新标签。

    如果你想为每支蜡烛创建标签,只需删除该条件即可。

    if (not na(stopLossPrice))
        label.new(bar_index, stopLossPrice, text=StopLoseText, style=label.style_label_up, color=color.new(#00f708, 100), textcolor=color.rgb(255, 153, 0), size=size.small)
    

    笔记 您应该确保 止损价格 将设置为 na 当不使用时。否则,它将继续创建标签。

    推荐文章