'An argument of 'float[]' type was used but a 'series float' is expected

I wrote this code in pinescript:

kijen_forw(period ) =>
    kjf = array.new_float(20)
    for i = 1 to period
        array.set(kjf,i,donchian(kijensenPeriods-i))
    kjf
kjf_draw = kijen_forw(10)
plot(kjf_draw , color=color.new(color.yellow,00) , linewidth=2 
,offset=10 , show_last=10 ,title="Kijensen Forward" )

But I get this error : Cannot call 'plot' with argument 'series'='kjf_draw'. An argument of 'float[]' type was used but a 'series float' is expected



Solution 1:[1]

Your function returns kjf which is an array. Then you are trying to plot an array which is not possible. Your function should return a numerical value.

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