[英]How to use default values for array parameters in pine-script functions?
Pine-script;松脚本;
Is there a way to provide default array value?有没有办法提供默认数组值?
For example:例如:
// @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)) => ...
You cannot provide default value as an array.您不能提供默认值作为数组。 And array argument cannot be omitted.并且数组参数不能省略。
In the future there will be way to assign int[] b = na
in the function signature.将来会有办法在 function 签名中分配int[] b = na
。 After that you will be able to check if passed array is 'na', and then reassign it.之后,您将能够检查传递的数组是否为“na”,然后重新分配它。
It will be possible to do something like this:可以这样做:
// @version=5
library("mylibrary", overlay = true)
export calc(int[] b = na) =>
arr = na(b) ? array.from(1,2) : b
array.size(b)
plot(calc())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.