Actions are elements tied to a user set condition producing a specific effect when the assigned condition is true. These allow users to have more control over their scripted alert, from invalidating sequences, to plotting graphical elements on the chart.

Actions always have the structure @keyword() = ..., starting with @, with an identifier, and ().

= will assign to the action a condition. When the assigned condition is true the action will trigger.

Like functions in classical programing languages, actions can have arguments located within (), adding further degrees of control over the action.

All actions arguments are optional.

This page lists out the available actions syntax as well as their utility.

@alert

The @alert action allows users to get alerted when the associated condition is true.

@alert(message)

Arguments

message (string): Alert message. Default is the associated condition.

Examples

// Send an alert when close > open
@alert(close is greater than open) = {close} > {open}

@label

The @label action allows users to draw labels on the toolkit pane when the associated condition is true.

Syntax

@label(y, text, text_color, color, style, size)

Arguments

y (placeholder): y coordinate value of the label. Accepts data placeholders as values. Default is "{close}".

text (string): text displayed on the label. Default text is the condition.

Placeholders can be used within the text, these will be replaced with the corresponding value. For example:

@label(text="closing price: {close}")

color (color): color of the label. Possible values include:

"black", "silver", "gray", "white", "maroon", "purple", "fuchsia", "green", "red", "lime", "olive", "yellow", "navy", "blue", "teal", "aqua", "orange"

Default is the opposite color to the chart background.

text_color (color): color of the text displayed on the label. Possible values include:

"black", "silver", "gray", "white", "maroon", "purple", "fuchsia", "green", "red", "lime", "olive", "yellow", "navy", "blue", "teal", "aqua", "orange"

Default is the chart background color.

style (string): Shape of the displayed label, possible values include:

  • "none"
  • "xcross"
  • "cross"
  • "triangleup"
  • "triangledown"
  • "flag"
  • "circle"
  • "arrowup"
  • "arrowdown"
  • "label_up"
  • "label_down"
  • "label_left"
  • "label_right"
  • "label_lower_left"
  • "label_lower_right"
  • "label_upper_left"
  • "label_upper_right"
  • "label_center"
  • "square"
  • "diamond"

Default is "label_down"

Examples

// Draw a label when close > open
@label(y="{close}", text="Up", color="green", text_color="white", style="label_up", size="small") = {close} > {open}

Remarks

Currently, the value in y does not fully support historical referencing.

@line

The @line action allows users to draw lines on the toolkit pane when the associated condition is true.

Syntax

@line(x1, y1, x2, y2, color)

Arguments

x1 (integer): How far ahead from the current bar the x1 coordinate of the line is located. Accepts negative values. Default is "0".

y1 (placeholder): y1 coordinate value of the line. Accepts data placeholders as values. Default is "{close}" except for the Oscillator Matrix® which uses 50.

x2 (integer): How far ahead from the current bar the x2 coordinate of the line is located. Accepts negative values. Default is "0".

y2 (placeholder): y2 coordinate value of the line. Accepts data placeholders as values. Default is "{close}" except for the Oscillator Matrix® which uses 50.

color (color): color of the label. Possible values include:

"black", "silver", "gray", "white", "maroon", "purple", "fuchsia", "green", "red", "lime", "olive", "yellow", "navy", "blue", "teal", "aqua", "orange"

Default is "blue".

Examples

// Draw line if closing price cross over closing price 10 bars ago
@line(x1="-10", y1="{low}", x2="10", y2="{high}", color="green") = {close} crossover {close[10]}

Remarks

Currently, values of y1/y2 do not fully support historical referencing.

@valuewhen

Plot a user set value on the chart when the assigned condition is true.

Syntax

@valuewhen(source)

Arguments

source (placeholder): value to plot when the assigned condition is true, only supports placeholders. Default is {close} except for the Oscillator Matrix® which uses 50.

Examples

//Plot {high} when close crossover open
@valuewhen({high}) = {close} crossover {open}

Remarks

The plot for @valuewhen is accessible as input for other scripts with name “@Valuewhen”, also allowing users to create alerts using it.

@invalidate

Invalidate a sequence of condition when the assigned condition is True.

Syntax

@invalidate(step)

Arguments

step (integer, integer list): step to consider for invalidation, supports multiple values. If no steps are provided all steps will be evaluated.

Examples

// Alert when sequence is completed:
// step 1: closing price is above opening price
// step 2: closing price is above previous high

{close} > {open}
{close} > {high[1]}

// Invalidate sequence if opening price is lower than previous low
@invalidate() = {open} < {low[1]}

Example evaluating our invalidation condition on a specific step:

// Alert when sequence is completed:
// step 1: closing price is above opening price and volume is above 500
// step 2: closing price is above opening price and volume is above 1000
// step 3: closing price is under opening price

{close} > {open} and {volume} > 500
{close} > {open} and {volume} > 1000
{close} < {open}

// Invalidate sequence if closing price is lower than opening price
// when we are evaluating the second step (step=1)
@invalidate(step=1) = {close} < {open}

Example evaluating our invalidation condition on multiple step:

// Alert when sequence is completed:
// step 1: closing price is above opening price and volume is above 500
// step 2: closing price is above opening price and volume is above 1000
// step 3: closing price is above opening price and volume is above 1500
// step 4: closing price is above opening price and volume is above 2000
// step 5: closing price is under opening price

{close} > {open} and {volume} > 500
{close} > {open} and {volume} > 1000
{close} > {open} and {volume} > 1500
{close} > {open} and {volume} > 2000
{close} < {open}

// Invalidate sequence if closing price is lower than opening price
// when we are evaluating the second, third, and fourth step (step=1,2,3)
@invalidate(step=1,2,3) = {close} < {open}

@filter

Use the assigned condition as filtering condition for all or user defined steps.

Syntax

@filter(step)

Arguments

step (integer, integer list): step where the filtering condition is applied, supports multiple values. If no steps are provided all steps will have the filtering condition applied.

Examples

// Alert when sequence is completed:
// step 1: closing price is above opening price and volume > 500
// step 2: closing price is above previous high and volume > 500

{close} > {open}
{close} > {high[1]}

// Apply our previously defined volume > 500 filter
@filter() = {volume} > 500

Example providing different filters across steps:

// Alert when sequence is completed:
// step 1: closing price is above opening price and volume is above 1000
// step 2: closing price is above opening price and volume is above 1000
// step 3: closing price is above opening price and volume is above 2000
// step 4: closing price is above opening price and volume is above 2000
// step 5: closing price is under opening price

{close} > {open}
{close} > {open}
{close} > {open}
{close} > {open}
{close} < {open}

// Apply our previously defined volume > 1000 filter to step 1 and 2
@filter(step=0,1) = {volume} > 1000

// Apply our previously defined volume > 2000 filter to step 3 and 4
@filter(step=2,3) = {volume} > 2000

@set_step

Set the sequence step to a user defined value, or increase/decrease the current set by a user set increment/decrement.

Syntax

@set_step(value)

Arguments

value (integer): New value of the step. Users can also increase the current step value using + as prefix, e.g: +1, or decrease it using - as prefix, e.g: -1.

Example

// Define UDPs
{bull} = {close} > {open}
{bear} = {close} < {open}
{bull+} = {close} > {high[1]} and {bull}
{bear+} = {close} < {low[1]} and {bear}

// Define sequence
{bull} // Step 1
{bear} // Step 2
{bull+} // Step 3
{bear+} // Step 4

// Reset sequence to corresponding step
@set_value(0) = {bull} // Reset to step 1
@set_value(1) = {bear} // Reset to step 2
@set_value(2) = {bull+} // Reset to step 3

Remarks

Users cannot set a negative value for a step (e.g: @set_step(-1)), which would instead set the step to 0, however, the step can become negative when using increments/decrements.