Jonathan S
Jonathan S

Reputation: 39

Pine script Mismatched input '' expecting 'end of line without line continuation'

I'm thinking of creating a trendline on pine script as an average of three different trend lines. So far if I just use 1 it works, but if use an average of 3, it comes up with the error: Mismatched input 'bearish' expecting 'end of line without line continuation'.

trendLength_1 = input(title = "Trend Length_1:", defval = 10)
trendLength_2 = input(title = "Trend Length_2:", defval = 20)
trendLength_3 = input(title = "Trend Length_3:", defval = 30)

trend_1 = lowest(security_low, trendLength_1) + ((highest(security_high, trendLength_1) - lowest(security_low, trendLength_1)) / 2)
trend_2 = lowest(security_low, trendLength_2) + ((highest(security_high, trendLength_2) - lowest(security_low, trendLength_2)) / 2)
trend_3 = lowest(security_low, trendLength_3) + ((highest(security_high, trendLength_3) - lowest(security_low, trendLength_3)) / 2)
trend = (0.5 * trend_1) + (0.3 * trend_2) + (0.2 * trend_3)

bearish = true

for i = 0 to trendConfirmationLength - 1
        bearish := bearish and (security_close[i] < trend[i])

Thank you

Upvotes: 1

Views: 4151

Answers (1)

Bjorn Mistiaen
Bjorn Mistiaen

Reputation: 6865

Your indentation is too large, because you're using 2 tabs.

for i = 0 to trendConfirmationLength - 1
        bearish := bearish and (security_close[i] < trend[i])

Should be only 1 tab.

for i = 0 to trendConfirmationLength - 1
    bearish := bearish and (security_close[i] < trend[i])

Upvotes: 1

Related Questions