显示策略回测条目的特定评论

display specific comments for strategy backtest entries

当使用以下代码通过不同的选项退出策略时:

strategy.exit("x", from_entry="Short", qty = initial_position_size * short_TP1_Ratio, limit = short_TP1, stop=short_SL, comment="SL/TP")

当策略在 stop 退出时显示诸如“SL”之类的评论,当策略在 limit 退出时显示“TP”之类的评论而不是通用评论?

我尝试了不同的方法,例如将 close/high/low 价格与当前 sl_price 价格进行比较,但我最终得到的结果在某些情况下似乎过于冗长且不稳定。如果有的话,在 pine 中实现此目标的最佳方法是什么?

这可以帮助:

//strategy.exit("x", from_entry="Short", qty = initial_position_size * short_TP1_Ratio, limit = short_TP1, stop=short_SL, comment="SL/TP")
if strategy.position_size < 0
    strategy.order("sl", strategy.long, qty = initial_position_size * short_TP1_Ratio, stop=short_SL, oca_name = "exit short", oca_type = strategy.oca.reduce, comment="SL")
    strategy.order("tp", strategy.long, qty = initial_position_size * short_TP1_Ratio, limit = short_TP1, oca_name = "exit short", oca_type = strategy.oca.reduce, comment="TP")
else
    strategy.cancel("sl")
    strategy.cancel("tp")