April 22, 2014

Added Line Breaks and Multi-Line support to Pine Script!

Now you can fit any long statement in Pine Script into several lines.

Example 1

a = open + high + low + close

Can be separated as follows (like a ladder):

a = open +
        high +
            low +
               close

Note: We REALLY don’t recommend formatting every statement of your script like this 😉

Example 2

plot(correlation(src, ovr, length), color=purple, style=area, transp=40)

Can be separated as follows:

plot(correlation(src, ovr, length),
    color=purple,
    style=area,
    transp=40)

Example 3

updown(s) =>
    isEqual = s == s[1]
    isGrowing = s > s[1]
    ud = isEqual ? 0 : isGrowing ? (nz(ud[1]) <= 0 ? 1 : nz(ud[1])+1) : (nz(ud[1]) >= 0 ? -1 : nz(ud[1])-1)

Can be separated as follows:

updown(s) =>  
    isEqual = s == s[1]
    isGrowing = s > s[1]    
    ud = isEqual ?
           0 :
           isGrowing ?
               (nz(ud[1]) <= 0 ? 
                     1 :
                    nz(ud[1])+1) :
                (nz(ud[1]) >= 0 ?
                    -1 :
                    nz(ud[1])-1)