使用 `step_num` 进行循环的 Pine 脚本

问题描述 投票:0回答:1

任何人都知道为什么这个 for 循环会随着

-1
递增,即使我明确告诉它随着
+1
递增?

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/

// © mickes

//@version=5
indicator("Test for loop", overlay = true)

ii = ""
for i = 10 to 0 by +1
    ii += str.format(" {0}", i)
runtime.error(str.format("{0}", ii))
plot(close)
pine-script
1个回答
0
投票

是的,因为你的 for 循环从 10 开始一直到 0,无论是否明确给它 +1。您应该更改循环中的条件,如下所示:

for i = 0 to 10 by 1
© www.soinside.com 2019 - 2024. All rights reserved.