Jean-Baptiste Bolh
Jean-Baptiste Bolh

Reputation: 35

How to wrap long if statements in pinescript?

In pinescript is it possible to wrap a long if statement such that each condition is on a new line?

Example:

if condition_1 or condition_2 or condition_3
    //do something

Desired format:

if condition_1 or 
 condition_2 or 
 condition_3
    //do something

Upvotes: 1

Views: 2084

Answers (1)

mr_statler
mr_statler

Reputation: 2171

Yes. If it wraps to the next line then the continuation of the statement must begin with one or several (different from multiple of 4) spaces.

Here are some examples

For example with if condition:

//@version=5
indicator("My script")

condition1 = barstate.islast
condition2 = true

if condition1 and 
 condition2     // one space only
    label.new(bar_index, low, text="Hello, world!", style=label.style_circle)

Upvotes: 5

Related Questions