timeChange() 函数 returns 带有黄色警告。这是什么意思,或者只是如何解决它?松脚本 V5

timeChange() function returns with a yellow warning. What does it mean or simply how to fix it? Pine Script 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

警告是: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.

有趣的是:PineScript 手册甚至不知道这个 timechange() 函数,V4 和 V5 都不知道。

因此,通过在三元运算符中调用该函数,您打破了历史和一致性。并非所有这些函数都会在每次执行时被调用。

如果您想修复警告,请在全局范围内使用这些函数,将它们的结果分配给一个变量,然后在三元运算符中使用这些变量。