任何人都知道为什么这个 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)
是的,因为你的 for 循环从 10 开始一直到 0,无论是否明确给它 +1。您应该更改循环中的条件,如下所示:
for i = 0 to 10 by 1