'Formatting conditional structures in Pine Script?

I'd like to have my code a little bit cleaner, so I wish to use a new line for each one of my conditions concurring to create a certain "group" of strategy.entry conditions. Easier to show than to tell. See the following:

one of my strategy.entry condition "groups":

ent_FishLow() =>
    inDateRange == true
    mmfast>mmslow
    rsi<35
    fish1<-3

The actual entry process, which evaluates if this or another group is verified:

if ent_RSILow() or ent_FishLow() or ent_TrendUP_FishLow() or...
    strategy.entry()

BUT... it doesnt work unless I format all that stuff in one line, annding the operator AND between conditions with the result of being less readable and user friendly, like that:

ent_FishLow() =>
    inDateRange == true and mmfast>mmslow and rsi<35 and fish1<-3

Is there anything I can do to put those conds in different lines?



Solution 1:[1]

First of all, you are missing the and and or operators in the following function:

ent_FishLow() =>
    inDateRange == true
    mmfast>mmslow
    rsi<35
    fish1<-3

You another problem is, when you want to have multi line statements, your next line should begin with one or several (different from multiple of 4) spaces.

The following example works without any problems.

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

r = ta.rsi(close, 14)
a = ta.atr(10)

_l() =>
    r > 40 and
      a > 4  // Note the indentation

plot(_l() ? 1 : 0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vitruvius