TimeChange()功能带有黄色警告。这是什么意思,或者简单地修复它? PINE脚本V5

发布于 2025-01-26 02:38:07 字数 644 浏览 2 评论 0原文

isNewPeriod = anchor == "Earnings" ? new_earnings :
 anchor == "Dividends" ? new_dividends :
 anchor == "Splits" ? new_split :
 na(src[1]) ? true :
 anchor == "Session" ? timeChange("D") :
 anchor == "Week" ? timeChange("W") :
 anchor == "Month" ? timeChange("M") :
 anchor == "Quarter" ? timeChange("3M") :
 anchor == "Year" ? timeChange("12M") :
 anchor == "Decade" ? timeChange("12M") and year % 10 == 0 :
 anchor == "Century" ? timeChange("12M") and year % 100 == 0 :
 false

警告是:应在每个计算上调用函数'timechange'以达到一致性。建议从三元操作员或范围提取呼叫。

有趣的是:Pinescript手册甚至不知道此timechange()函数,既不是V4和V5 。

isNewPeriod = anchor == "Earnings" ? new_earnings :
 anchor == "Dividends" ? new_dividends :
 anchor == "Splits" ? new_split :
 na(src[1]) ? true :
 anchor == "Session" ? timeChange("D") :
 anchor == "Week" ? timeChange("W") :
 anchor == "Month" ? timeChange("M") :
 anchor == "Quarter" ? timeChange("3M") :
 anchor == "Year" ? timeChange("12M") :
 anchor == "Decade" ? timeChange("12M") and year % 10 == 0 :
 anchor == "Century" ? timeChange("12M") and year % 100 == 0 :
 false

Warning is: The function 'timeChange' should be called on each calculation for consistency. It is recommended to extract the call from the ternary operator or from the scope.

The interesting thing is: the PineScript Manual doesn't even know this timechange() function, neither V4 nor V5.

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

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

发布评论

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

评论(1

小红帽 2025-02-02 02:38:07

因此,通过在三元运营商中调用该功能,您正在破坏历史记录和一致性。并非所有这些函数都会在每个执行中调用。

如果要修复警告,请在全局范围中使用这些功能,将其结果分配给变量,然后在三元运算符中使用这些变量。

So, by calling that functions within the ternary operators, you are breaking the history and consistency. Not all those functions will be called on each execution.

If you want to fix the warning, use those functions in the global scope, assign their results to a variable and use those variables in the ternary operator instead.

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