By default, when using a for loop, the loop's variable is incremented by 1 after each iteration.
Let's look at how we can specify a custom step.
All we need to do is add the keywordfollowed by a Number, like this:
In the example above, we're using aof , adding up every other value of .
QuantScript also supports negative steps:
In the example above, we're going backwards fromto . The code is equivalent to the following sum: .
If we use a step larger than, the loop's variable may "jump over" the value. In this case, the loop stops and no futher iterations are performed.