繁体   English   中英

无法在 strategy.exit 中调用“when”条件

[英]Unable to invoke `when` condition in strategy.exit

只有when设置条件时,我才能使 strategy.exit 正常工作。 我写的代码如下:

strategy.entry("buy", strategy.long, when=rsi(close, 14) < 30)
strategy.exit("sell", "buy", qty_percent=100, when=rsi(close, 14) > 70)

如果我在exit添加任何其他条件,则会触发卖出。 有人可以帮我理解我做错了什么吗?

提前致谢。

正如官方文档所说

如果以下所有参数'利润'、'限制'、'损失'、'停止'、'trail_points'、'trail_offset' 都是'NaN',则命令将失败。 要使用市价单退出,应使用命令 strategy.close 或 strategy.close_all。

https://www.tradingview.com/pine-script-reference/v4/#fun_strategy {dot}exit

所以它不适用于其他参数。 when只是何时下订单,但至少必须有一些额外的参数,例如“利润”。

如果您想按市场退出,请使用strategy.close

实际上有一个警告。

警告

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM