【发布时间】:2021-06-03 09:30:17
【问题描述】:
我是 Pine 脚本的新手,所以请耐心等待。我试图弄清楚当“多头”条件变为真时如何绘制买入标签,但只是第一次而不是每个柱条件都为真。所以基本上,“strategy.entry”和“strategy.close”打开和关闭一个位置的方式相同。
if (longConditions)
strategy.entry("Long", true)
longLabel = label.new(
x=bar_index,
y=na,
text="Long",
xloc=xloc.bar_index,
yloc=yloc.belowbar,
color=color.green,
textcolor=color.white,
style=label.style_label_up,
size=size.normal)
if (closeLongConditions)
strategy.close("Long")
closeLongLabel = label.new(
x=bar_index,
y=na,
text="Close",
xloc=xloc.bar_index,
yloc=yloc.abovebar,
color=color.red,
textcolor=color.white,
style=label.style_label_down,
size=size.normal)
有没有办法让“strategy.entry”和“strategy.close”触发标签而不是我的“long”和“close”条件?
【问题讨论】:
-
我想出了一个可行的解决方案。如果有人想插话,我很想看看其他方法。但我使用了一个 var 变量和一个开关来禁止生成重复的“长”标签,直到“关闭”信号重置开关。
标签: pine-script