将弹性作为arg将其传递给TradingView的另一个Func的Pinescript

发布于 2025-02-09 20:37:21 字数 517 浏览 0 评论 0原文

试图将功能作为ARG传递给另一个弹药...

1  //@version=5
2  indicator("My script")
3
4  f1() => 1
5  f2() => f1()
7    
8  // accept func as arg
9  f3() => 2
10 f4(func) =>
11     func()
12 
13 out1 = f2()
14 out2 = f4(f3)
15
16 if barstate.islastconfirmedhistory
17     label.new(bar_index, high, str.tostring(out1)) // returns 1 
18     label.new(bar_index, low, str.tostring(out2))  // returns error (see below)

给出错误: 添加到图表操作失败,原因:第11行:找不到函数或功能引用'func'。 有没有办法实现这一目标?谢谢!

trying to pass a func as an arg to another func...

1  //@version=5
2  indicator("My script")
3
4  f1() => 1
5  f2() => f1()
7    
8  // accept func as arg
9  f3() => 2
10 f4(func) =>
11     func()
12 
13 out1 = f2()
14 out2 = f4(f3)
15
16 if barstate.islastconfirmedhistory
17     label.new(bar_index, high, str.tostring(out1)) // returns 1 
18     label.new(bar_index, low, str.tostring(out2))  // returns error (see below)

gives error:
Add to Chart operation failed, reason: line 11: Could not find function or function reference 'func'.
is there a way to accomplish this? thx!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文