简体   繁体   中英

Pine script cannot return an array of linefills Pine script v5 [Bug report]

Study Error
Internal server pine compilation error

This basic example throws the exception above.

//@version=5
indicator("Test")

test() =>
    foo = line.new(bar_index,  close, bar_index + 1,  close, xloc.bar_index, color = color.red)
    bar = line.new(bar_index, open, bar_index + 1, open, xloc.bar_index, color = color.green)

    lf = linefill.new(foo, bar, color.new(color.red, 80))
    
    array.from(lf) // we want to return n number of linefills 

lf = test()

Is there a particular reason for that? I cannot think of any reason why a simple data type should be exempt from being returned as an array. It seems to be a pine script bug again.

As of today ( 2022-10-03 ), the bug was confirmed by the TradingView Pine Team and a task was opened to fix it.
Only workaround for now is to return a tuple of all the linefills there are like this:

test() =>  
    ...  
    [lf1, lf2, lf3]  

[linefill1, linefill2, linefill3] = test()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM