如何在 pine-script 函数中使用数组参数的默认值?

How to use default values for array parameters in pine-script functions?

松脚本;

有没有办法提供默认数组值?

例如:

// @version=5

library("mylibrary", overlay = true)

// This is OK
export calc(int a = 10, int[] b) => ...

// This is NOT OK
export calc(int a = 10, int[] b = array.from(1,2)) => ...

您不能提供数组形式的默认值。并且数组参数不能省略。

以后会在函数签名中赋值int[] b = na。之后,您将能够检查传递的数组是否为 'na',然后重新分配它。

将有可能做这样的事情:

// @version=5
library("mylibrary", overlay = true)

export calc(int[] b = na)  => 
    arr = na(b) ? array.from(1,2) : b
    array.size(b)
    
plot(calc())