如何在 pine-script 函数中使用数组参数的默认值?
松木;
- 库不能在导出功能中使用全局变量,因此我不能将全局数组用作默认值。
- 功能不接受函数结果为默认值。
有没有办法提供默认数组值?
例如:
// @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)) => ...
Pine-script;
- Libraries cannot use global variables in exported functions, so I cannot use a global array as a default value.
- Functions do not accept function results as default values.
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)) => ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能以数组形式提供默认值。并且数组参数不能省略。
将来将会有办法在函数签名中赋值
int[] b = na
。之后,您将能够检查传递的数组是否为“na”,然后重新分配它。可以做这样的事情:
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. After that you will be able to check if passed array is 'na', and then reassign it.It will be possible to do something like this: