无法在 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
中添加任何其他条件,则会触发卖出。谁能帮我理解我做错了什么?
提前致谢。
正如官方文档所说
If all the following parameters 'profit', 'limit', 'loss', 'stop',
'trail_points', 'trail_offset' are 'NaN', the command will fail. To
use market order to exit, the command strategy.close or
strategy.close_all should be used.
https://www.tradingview.com/pine-script-reference/v4/#fun_strategy{点}退出
因此它不适用于其他参数。 when
只是什么时候下单,但是至少要有一些额外的参数,比如'profit'.
如果您想按市场退出,请使用strategy.close
。
实际上有一个警告。
当只设置了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
中添加任何其他条件,则会触发卖出。谁能帮我理解我做错了什么?
提前致谢。
正如官方文档所说
If all the following parameters 'profit', 'limit', 'loss', 'stop', 'trail_points', 'trail_offset' are 'NaN', the command will fail. To use market order to exit, the command strategy.close or strategy.close_all should be used.
https://www.tradingview.com/pine-script-reference/v4/#fun_strategy{点}退出
因此它不适用于其他参数。 when
只是什么时候下单,但是至少要有一些额外的参数,比如'profit'.
如果您想按市场退出,请使用strategy.close
。
实际上有一个警告。