如果有连续的绘图标记,则标签仅显示在第一个标记上。有什么办法可以改变这种行为吗?我希望每个烛台都有 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)
如果是连续的绘图标记,则标签仅显示在第一个标记处。
您正在使用条件 (
(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)
注意: 您应确保在不使用时将
stopLossPrice
设置为na
。否则,它会继续创建标签。