[英]Check for strategy.long just opened in pine script v5
In my v4 script, I use the below to mark on a graph if a buy signal was received:在我的 v4 脚本中,如果收到买入信号,我会使用以下代码在图表上进行标记:
if strategy.long
stratstring := 'Buy'
In v5 strategy.long is no longer a bool, but a strategy_direction.在 v5 中,strategy.long 不再是 bool,而是 strategy_direction。 How do I change the if statement.如何更改 if 语句。 I imagine something like我想象像
if strategy.long == strategy_direction.long
but that does not exist...但那不存在...
Basically, I want to detect if a long signal was given in the current bar.基本上,我想检测当前柱线中是否给出了多头信号。
You can check if you are not already in a long trade and if your long condition is true as below:您可以检查您是否尚未进行多头交易,以及您的多头条件是否为真,如下所示:
buy_now = (strategy.position_size <= 0) and your_long_condition
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.