In my v4 script, I use the below to mark on a graph if a buy signal was received:
if strategy.long
stratstring := 'Buy'
In v5 strategy.long is no longer a bool, but a strategy_direction. How do I change the if statement. 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.