Pine 脚本 - 使用 strategy.order() 或 strategy.entry() 的括号顺序
Pine script - Bracket order using strategy.order() or strategy.entry()
我一直在尝试在一条消息中发送包含入场价、利润、损失的提醒(基本上是括号订单格式)。到目前为止,我是通过两条不同的消息得到它的。一个是在strategy.entry()期间,另一个是在strategy.exir()期间...总之可以一起发送吗?
在每个订单中使用 alert_message=
,但将 strategy.exit()
中的一个留空,然后使用 {{strategy.order.alert_message}}
占位符配置您的警报。
卢克夫,
使用以下代码达到要求。
'strategy.entry("Enter Short", strategy.short, 1, when = TradingTime, alert_message = 'Profit=' + tostring(high[1]-low[1]) + 'Loss=' + tostring(high[1]-low[1]) )'
占位符 {{strategy.order.alert_message}} 传递所需的值。 :)
感谢使用指导alert_message。
你可以尝试这样的事情。
创建两条不同的消息,一条用于买入,另一条用于卖出,然后在 Tradingview 脚本中使用相应的消息。在 entry 调用中编码的警报消息将在警报消息中被提取。
由于您正在寻找括号定单,因此您可以按照以下格式添加其他参数,例如盈亏。
buy_msg = "TYPE:LE "+" :SYMBOL: "+syminfo.ticker +" :PRICE: "+tostring(close)+" :QTY: "+tostring(quant)
sell_msg = "TYPE:Lx "+" :SYMBOL: "+syminfo.ticker +" :PRICE: "+tostring(close)+" :QTY: "+tostring(quant)
strategy.entry("Long", strategy.long, when = buy,comment="Buy",alert_message=buy_msg )
strategy.entry("Short", strategy.short, when = sell,comment="Sell",alert_message=sell_msg)
在最后一步中,您需要将消息指定为{{strategy.order.alert_message}}。请参阅随附的屏幕截图以供参考。
我一直在尝试在一条消息中发送包含入场价、利润、损失的提醒(基本上是括号订单格式)。到目前为止,我是通过两条不同的消息得到它的。一个是在strategy.entry()期间,另一个是在strategy.exir()期间...总之可以一起发送吗?
在每个订单中使用 alert_message=
,但将 strategy.exit()
中的一个留空,然后使用 {{strategy.order.alert_message}}
占位符配置您的警报。
卢克夫,
使用以下代码达到要求。
'strategy.entry("Enter Short", strategy.short, 1, when = TradingTime, alert_message = 'Profit=' + tostring(high[1]-low[1]) + 'Loss=' + tostring(high[1]-low[1]) )'
占位符 {{strategy.order.alert_message}} 传递所需的值。 :)
感谢使用指导alert_message。
你可以尝试这样的事情。 创建两条不同的消息,一条用于买入,另一条用于卖出,然后在 Tradingview 脚本中使用相应的消息。在 entry 调用中编码的警报消息将在警报消息中被提取。 由于您正在寻找括号定单,因此您可以按照以下格式添加其他参数,例如盈亏。
buy_msg = "TYPE:LE "+" :SYMBOL: "+syminfo.ticker +" :PRICE: "+tostring(close)+" :QTY: "+tostring(quant)
sell_msg = "TYPE:Lx "+" :SYMBOL: "+syminfo.ticker +" :PRICE: "+tostring(close)+" :QTY: "+tostring(quant)
strategy.entry("Long", strategy.long, when = buy,comment="Buy",alert_message=buy_msg )
strategy.entry("Short", strategy.short, when = sell,comment="Sell",alert_message=sell_msg)
在最后一步中,您需要将消息指定为{{strategy.order.alert_message}}。请参阅随附的屏幕截图以供参考。