Strategy.close 没有引用正确的值

Strategy.close not referencing correct value

这里是有问题的策略的link:

MACD Strategy

当我绘制 Long_SL、Long_TP、Short_SL 和 Short_TP 时,它们都以预期值出现。但是当我将它们用作 strategy.close 条件时,它们无法按预期工作。

可以在脚本的第 72 和 73 行中找到这方面的示例。

我对此很陌生,如有任何帮助,我们将不胜感激!

Long_SL >= low 条件永远不会为真,并且此 strategy.close() 永远不会执行:

if strategy.position_size > 0 and strategy.position_entry_name == "B" and Long_SL >= low
    strategy.close (id="B")

要检查它评论所有地块并添加

plot(low, color = color.red)
plot(Long_SL, color = color.orange)

使用bgcolor()检查条件总是很容易:

bgcolor(strategy.position_size > 0 and strategy.position_entry_name == "B" and Long_SL >= low ? color.red:na)