As a total beginner in Pine Script, I am trying to iteratively build an array based on the value of two variables. I come from Python experience and, looking at Pine Script documentation, I would expect it to be something similar to what I have tried below. However, I receive a "Mismatched input 'if' expecting 'end of line without line continuation'" error for the first "else if" statement. Does anyone have a second to find what is probably a trivial issue to a more experienced Pine Script coder? Thank you
Here is what I have at the moment:
//@version=5 indicator('Automated Label') past_return = input(10, "Old return - Consider return x old candles") more_recent_return = input(5, "Recent return - Consider return x old candles") Rtd1 = (close - close[past_return]) / close[past_return] Rtd2 = (close - close[more_recent_return]) / close[more_recent_return] pre_label = array.new_float(0) if Rtd1 > 0 and Rtd2 > 0 if Rtd1 > Rtd2 array.push(pre_label, value=4) else array.push(pre_label, value=3) else if Rtd2 > 0 array.push(pre_label, value=1) else if Rtd1 < 0 and Rtd2 < 0) if Rtd1 < Rtd2 array.push(pre_label, -4) else array.push(pre_label, -3) else if Rtd2 < 0 array.push(pre_label, -1) else array.push(pre_label,0)