Sidechair

Annotations

Browse the reference

Compiler annotations written as //@ comments: the version line, and the documentation tags for libraries and strategy alert messages.

Try it in the editor

An annotation is a special comment that starts //@. It does not run, but the editor and the compiler read it. //@version=6 on the first line picks the language version. A script that leaves it out is read as version 1 by TradingView; Sidechair reads it as version 5.

The documentation annotations describe code for the people who use it: @function, @param and @returns go above a function or method, @type and @field above a user-defined type, @enum above an enum, @variable above a variable and @description at the top of a library. The text appears in tooltips when someone hovers the name, and in a library's published page.

//@strategy_alert_message sets the text that fills the message box when someone creates an alert from a strategy, and may use placeholders such as {{strategy.order.action}}.

Annotations

AnnotationSyntaxDescription
@description//@description <text>Describes a library as a whole. Goes at the top, above the library() declaration.
@enum//@enum <text>Describes an enum. Goes above the enum declaration; list its fields with @field.
@field//@field <name> <text>Describes one field of a user-defined type or enum, under its @type or @enum line.
@function//@function <text>Describes a function or method. Goes above it, with @param and @returns lines.
@param//@param <name> <text>Describes one parameter of a function or method, named exactly as in its header.
@returns//@returns <text>Describes what a function or method returns.
@strategy_alert_message//@strategy_alert_message <message>Sets the default text of the alert message box for strategy alerts. May use placeholders such as {{ticker}}.
@type//@type <text>Describes a user-defined type. Goes above the type declaration; list its fields with @field.
@variable//@variable <text>Describes a variable. Goes above its declaration.
@version=//@version=<n>Chooses the Pine version for the script. Goes on the first line; 6 is the current version. A script without it is treated as version 1 by TradingView and as version 5 on Sidechair.

Remarks

  • Annotations go on the lines directly above what they describe, with no blank line in between.
  • On Sidechair: //@version is read from the first lines. The other annotations are plain comments and do not change how the script runs.

Example

Pine ScriptA documented functionOpen in editor
//@version=6
indicator("Documented", overlay = true)

//@function Smoothed range of the last bars, in price units.
//@param len Number of bars to include.
//@returns The average of high minus low over len bars.
avgRange(int len) =>
    ta.sma(high - low, len)

//@variable The average range of the last 14 bars.
r = avgRange(14)
plot(close + r, "Upper", color.green)
plot(close - r, "Lower", color.red)

See also

Runs on Sidechair