我有一个松树脚本策略,它使用:
strategy.entry("Long", strategy.long, when = cond1)
strategy.entry("Short", strategy.short, when = cond2)
strategy.close("Long", when = cond3)
strategy.exit(id="TrailStop", stop=shortStopPrice)
现在我正在设置需要输出特定信息的 Tradingview 警报。
我可以使用 {{strategy.order.action}}
输出买入或卖出,但我还需要输出词close 或 open。您知道如何在警报消息框中获取此值吗?它是否存在于某种标准的策略变量中?或者我可以在脚本中分配它并在警报框中调用它吗?
更新:根据 bjorn-mistiaen 的回答,我添加了评论。它适用于 .entry 和 .exit,但不适用于 .close:
strategy.close(id = "Long", when = cond3, comment="test")
返回:
Hoovering 函数告诉我注释是一个有效的参数。我不太明白调试错误消息。
答案 0 :(得分:2)
您可以尝试使用 {{strategy.order.comment}}
这将返回已执行订单的注释(在 生成订单的函数调用之一中的注释参数: 策略.进入、策略.退出或策略.顺序)。如果没有评论是 指定,则将使用 strategy.order.id 的值。
来源:How to use a variable value in alert
comment
是 strategy.entry() 中的一个参数,您可以为它提供字符串 open
和 close
。
strategy.entry(id, long, qty, limit, stop, oca_name, oca_type, comment, when, alert_message)