Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pine script 为什么这个函数返回整数系列?_Pine Script - Fatal编程技术网

Pine script 为什么这个函数返回整数系列?

Pine script 为什么这个函数返回整数系列?,pine-script,Pine Script,为什么这个函数返回整数系列 称之为 d=查找_bartime,20 当我使用lowestclose时,d 我得到一个错误,d是整数系列 find_bar(time_array,bar) => counter = bar o = 0 what = time_array[0] if bar == 0 0 else for i = 1 to 100000

为什么这个函数返回整数系列

称之为 d=查找_bartime,20

当我使用lowestclose时,d 我得到一个错误,d是整数系列

find_bar(time_array,bar) =>
        counter = bar
        o = 0
        what = time_array[0]
        if bar == 0
            0
        else
            for i = 1 to 100000
                if time_array[i]-what[0]!=0
                    counter:= counter - 1
                    what:= time_array[i]
                    if counter == 0
                        o := i
                        break
            o[0]

这里有两件事

pine脚本中的1[]运算符返回序列类型的值。因此,o[0]是一个系列类型,因此函数返回一个系列类型的值


2:=运算符正在为变量赋值。这使它成为一个系列类型。原因是,对于每个新条,脚本都将重新执行:=将在case o历史中向变量添加一个新值。因此,它成为一个具有历史值的系列类型变量。您可以使用[]运算符访问这些历史值。

在这种情况下,有没有办法避免返回序列类型?@Aftershock,很遗憾,没有。