Reputation: 1
I am not a pinescript ninja. I am working on to finalize a strategy but it keeps giving me an error 'end of line without line continuation'. I have formatted code multiple time by 4 spaces or a tab but it won't work. I have tried here and chat gpt but I can't make it work. it keeps giving me error
How can I share my code here or if someone can message me directly to fix the problem. It is driving me crazy. Here is the code and there are different versions I have tried as below in my own replies. If someone can help me, that would be great.
BP = iff(close < open,
iff(close[1] < open, math.max(high - close[1], close - low),
math.max(high - open, close - low)),
iff(close > open,
iff(close[1] > open, high - low,
math.max(open - close[1], high - low)),
iff(high - close > close - low,
iff(close[1] < open, math.max(high - close[1], close - low), high - open),
iff(high - close < close - low,
iff(close[1] > open, high - low,
math.max(open - close[1], high - low)),
iff(close[1] > open, math.max(high - open, close - low),
iff(close[1] < open, math.max(open - close[1], high - low),
high - low)))))))
Upvotes: 0
Views: 51
Reputation: 1214
To avoid an if chain, try a switch
var BP = 0.0
switch
close[1] < open => BP := math.max(high - close[1], close - low)
close[1] > open => BP := math.max(high - open, close - low)
Upvotes: 0