Reputation: 1
Can someone help me convert this to a newer pine script? version. 4 or 5 for some reason i tried different syntax and can't get it to work. Thanks in advance
pos = iff(signal < macd , 1,
iff(signal > macd, -1, nz(pos[1], 0)))
Upvotes: 0
Views: 1469
Reputation: 21294
You should use the ternary operator.
var pos = 0
pos := (signal < macd) ? 1 : (signal > macd) ? -1 : nz(pos[1], 0)
Upvotes: 3