[英]Pine script - Bracket order using strategy.order() or strategy.entry()
我一直在尝试在一条消息(基本上是括号定单格式)中发送应包含入场价格、利润、损失的警报。 到目前为止,我通过 2 条不同的消息得到它。 一个是在 strategy.entry() 期间,另一个是在 strategy.exir() 期间......无论如何它可以一起发送吗?
卢卡夫,
使用以下代码实现要求。
' 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的指导。
在每个订单中使用alert_message=
,但将strategy.exit()
中的那个设置为空,然后使用{{strategy.order.alert_message}}
占位符配置您的警报。
你可以尝试这样的事情。 创建两条不同的消息,一条用于买入,另一条用于卖出,然后在 Tradingview 脚本中使用相应的消息。 然后,在入口调用中编码的警报消息将在警报消息中被拾取。 由于您正在寻找括号定单,您可以按以下格式添加其他参数,例如损益。
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)
在最后一步中,您需要将 Message 指定为 {{strategy.order.alert_message}}。 请参阅随附的屏幕截图以供参考。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.