1

I keep getting this error message

no viable alternative at character '{'

when trying to compile my code in pinescript version 5.

My code is as follows:

// Create alerts based on candle close type and input
if syminfo.ticker == symbolToMonitor and timeframe.period == timeframeToMonitor and my_input == "default_value" {
    alertcondition(bullish, title="Bullish Candle Close", message=bullishDefaultMsg);
    alertcondition(bearish, title="Bearish Candle Close", message=bearishDefaultMsg);
    alertcondition(doji, title="Doji Candle Close", message=dojiDefaultMsg);
}

This block of code is responsible for creating alerts based on the candle close type and the user input. The first if statement checks whether the current symbol, timeframe, and input match the default values set by the user. If they match, then it creates alerts using the default message strings for each candle close type.

I have tried adding the semicolons after each alertcondition() function call, as well as placing the opening curly brace on the same line as the if statement.

I have also tried replacing the curly braces {} with parentheses () and adding semicolons ; at the end of each line.

Neither of these solutions work.

vitruvius
  • 15,740
  • 3
  • 16
  • 26
Ola
  • 11
  • 1

1 Answers1

1

pinescript does not have {} or ;. Learn the syntax from here.

if <expression>
    <local_block>
{else if <expression>
    <local_block>}
[else
    <local_block>]
vitruvius
  • 15,740
  • 3
  • 16
  • 26