您可以使用Pinescript中的循环声明变量(专门的线变量)吗?

发布于 2025-02-13 15:46:43 字数 528 浏览 1 评论 0原文

是否可以通过循环声明线变量?

根据用户输入指定的数字,在表单,line2等上声明多个行变量的指示器,但不确定是否不可能,或者我只是对结构和语法很糟糕。

而不是:

UInput = input.int(n,"User defined input"....
var line1 = line.new(na,na,na,na
var line2 = line.new(na,na,na,na,......
....
var linen = line.new(na,na,na,na,......

n可能是50或更多的想做的事情:

UInput = input.int(n,"User defined input"....
for i = 0 to (n-1)
   var linei = line.new(na,na,na,na,......

我尝试使用“行”+str.tostring(i)尝试了一些变体,但不确定如何将其返回为行类型类型。

这是可行的还是单独声明的情况?

Is it possible to declare line variables via a loop?

Working on an indicator in which I would like to declare multiple line variables in the form line1, line2 etc based on a number specified by user input but not sure if it is not possible or I just suck at structure and syntax.

Instead of:

UInput = input.int(n,"User defined input"....
var line1 = line.new(na,na,na,na
var line2 = line.new(na,na,na,na,......
....
var linen = line.new(na,na,na,na,......

As n could be 50 or more would like to do something along the lines of:

UInput = input.int(n,"User defined input"....
for i = 0 to (n-1)
   var linei = line.new(na,na,na,na,......

I have tried a few variations using "line"+str.tostring(i) but not sure how to return that as line type instead of string type.

Is this doable or is it a case of declaring individually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狼性发作 2025-02-20 15:46:43

是的,这是可能的。您只需要声明一系列线条,然后将循环中的每条新线推入数组。

Yes, that's possible. You just need to declare an array of lines and push each new line in your loop into your array.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文