Sidechair

once

Browse the reference

A Pine v6 statement form, once [condition] followed by an indented block, that Sidechair does not run yet.

Try it in the editor

once is listed among the v6 keywords with the form once [condition], followed by statements on indented lines like the body of an if. The condition is optional.

Sidechair does not parse it yet, so a script that uses it stops at compile time. To run a block a single time on every version, keep a var flag and set it after the first run, as in the example.

Syntax

once [condition] statements

Remarks

  • On Sidechair: not supported yet; a script that uses once does not compile.

Example

Pine ScriptRun a block one time with a var flagOpen in editor
//@version=6
indicator("First gap up", overlay = true)
var bool done = false
if not done and open > high[1]
    done := true
    label.new(bar_index, high, "first gap up", color = color.green, textcolor = color.white)
plot(close, "Close", color.gray)

See also

Runs on Sidechair