PineScript中用于“根据给定序列值计算序列的索引值”的常规数学公式

the regular math formula for "Calculating the index value of a sequence based on a given sequence value." in PineScript

提问人:Kamaal 提问时间:7/7/2023 更新时间:7/7/2023 访问量:15

问:

我在 Pinescript 中遇到有关如何执行此操作的错误 currentIndex = ceil((sqrt(8 * sequenceValue + 1) - 1) / 2)

currently at // 根据 sequenceValue 更新 currentIndex currentIndex := round((sqrt(float(8 * sequenceValue + 1)) - 1) / 2, round_half_up) 任何帮助将不胜感激。

表达式的常规数学公式如下:ceil((sqrt(8 * sequenceValue + 1) - 1) / 2)

  1. 计算最内层的表达式:。8 * sequenceValue + 1
  2. 取步骤 1 中结果的平方根:。sqrt(8 * sequenceValue + 1)
  3. 从步骤 2 的结果中减去 1:。sqrt(8 * sequenceValue + 1) - 1
  4. 将步骤 3 的结果除以 2: 。(sqrt(8 * sequenceValue + 1) - 1) / 2
  5. 将 ceiling 函数应用于步骤 4 的结果:。ceil((sqrt(8 * sequenceValue + 1) - 1) / 2)

总之,该公式计算 的平方根 ,减去 1,除以 2,然后使用 ceiling 函数向上舍入到最接近的整数。(8 * sequenceValue + 1)

数学 索引 公式 序列 CEIL

评论


答: 暂无答案