Sidechair

continue

Browse the reference

Skips the rest of the current pass of a loop and moves on to the next one.

Try it in the editor

continue jumps to the next pass of the innermost for, for...in or while loop. In a for loop the counter still advances; in a while loop the condition is tested again. It saves nesting an entire body inside an if when only some passes need work.

Statements after continue in the same pass do not run.

Remarks

  • continue outside a loop is a compile error.

Example

Pine ScriptSum only the up barsOpen in editor
//@version=6
indicator("Continue")
total = 0.0
for i = 0 to 19
    if close[i] <= open[i]
        continue
    total += close[i] - open[i]
plot(total, "Up-bar body total", color.green, style = plot.style_area)

See also

Runs on Sidechair