Skip to main content
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 have the structure @keyword(), starting with @, with an identifier, and ().Some actions can have a condition assigned to them using =. When the assigned condition is true the action will be executed.
Like functions in classical programing languages, actions can have arguments located within (), adding further degrees of control over the action. On the other hand, methods work similarily but are tied to a UDP, changing its properties. This page lists out the available actions and methods syntax as well as their utility.

@alert

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

Syntax

@alert("message")

Arguments

message (string): Optional. Alert message used by the alert. Data placeholders can be used, these will be replaced by their corresponding value when the alert triggers. If not provided will use the associated condition.

Examples

// Send an alert when close > open
@alert("close is greater than open") = {close} > {open}
// Send an alert when close > open, with alert message returning the closing price value
@alert("price is {close}") = {close} > {open}

Remarks

In order for the alert to trigger, users must create an alert using as condition “any alert() function call”.

@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 or value): Optional. Location of the label. Accepts data placeholders as values. Default is {close} for toolkits appearing on the chart, and 50 for the Oscillator Matrix® toolkit. text (string): Optional. 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}")
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", "transparent", "chart.bg_color", "chart.fg_color"
Default is the chart background color "chart.bg_color". color (color): Optional. color of the label. Possible values include:
"black", "silver", "gray", "white", "maroon", "purple", "fuchsia", "green", "red", "lime", "olive", "yellow", "navy", "blue", "teal", "aqua", "orange", "transparent", "chart.bg_color", "chart.fg_color"
Default is the color to the chart background "chart.fg_color". style (string): Optional. 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" size (string): Optional. Size of the displayed label. Possible values include:
  • "auto" (automatically size the label based on the screen resolution)
  • "tiny"
  • "small"
  • "normal"
  • "large"
  • "huge"

Examples

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

@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): Optional. Data placeholder of the x1 coordinate of the line or a constant integer determining how far ahead/behind from the current bar the x1 coordinate is located. Accepts negative values. Default is 0. y1 (placeholder): Optional. y1 coordinate value of the line. Accepts data placeholders as values. Default is "{close}" except for the Oscillator Matrix® which uses 50. x2 (integer): Optional. Data placeholder of the x2 coordinate of the line or a constant integer determining how far ahead/behind from the current bar the x2 coordinate is located. Default is 0. y2 (placeholder): Optional. y2 coordinate value of the line. Accepts data placeholders as values. Default is "{close}" except for the Oscillator Matrix® which uses 50. color (color): Optional. color of the label. Possible values include:
"black", "silver", "gray", "white", "maroon", "purple", "fuchsia", "green", "red", "lime", "olive", "yellow", "navy", "blue", "teal", "aqua", "orange", "chart.bg_color", "chart.fg_color"
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]}
// Draw line if closing price cross over closing price 10 bars ago
@line(x1={barindex[10]}, y1={low}, x2={barindex}, y2={high}, color="green") = {close} crossover {close[10]}

@valuewhen

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

Syntax

@valuewhen(source, reference)

Arguments

source (placeholder): Optional. Value to plot when the assigned condition is true. Default is {close} except for the Oscillator Matrix® which uses 50. reference (string): Optional. Placeholder string used to reference the value in the script.

Examples

// Plot {high} when close crossover open
@valuewhen({high}) = {close} crossover {open}
// Record the value of {high} when close crossover open 
// Reuse the value as y coordinate for label
@valuewhen({high}, "{cross_high}") = {close} crossover {open}

@label({cross_high}) = {close} > {open}

Remarks

The plot for @valuewhen is accessible as input for other scripts with name “@Valuewhen”, also allowing users to create alerts using it. When multiple @valuewhen actions are defined the last one in the script will be ploted.
When specifying a reference placeholder in @valuewhen, the value will not be ploted.

Methods

Methods are similar to actions however they directly affect specific user set UDP’s, changing their properties. We say that methods are attached to UDP’s.
Methods have the structure {udp}.keyword(), with an UDP followed by . then an identifier keyword, and ().Some methods can have a condition assigned to them using =. When the assigned condition is true the method will be executed.

invalidate

Invalidate the UDP when the trigger condition is true.

Syntax

{udp}.invalidate(step)

Arguments

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

Examples

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

// Define sequence:
// step 1: closing price is above opening price
// step 2: closing price is above previous high

{my_sequence} = {close} > {open} then {close} > {high[1]}
Example evaluating our invalidation condition on a specific step:
// Invalidate sequence if closing price is lower than opening price
// when we are evaluating the second step (step=1)
{my_sequence}.invalidate(step=1) = {close} < {open}

// Define sequence:
// 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

{my_sequence} = {close} > {open} and {volume} > 500 then {close} > {open} and {volume} > 1000 then {close} < {open}
Example evaluating our invalidation condition on multiple step:
// Invalidate sequence if closing price is lower than opening price
// when we are evaluating the second, third, and fourth step (step=1,2,3)
{my_sequence}.invalidate(step=1,2,3) = {close} < {open}

// Define sequence:
// 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

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

Remarks

The invalidate method can work similarily to inline invalidation using the operator !. Consider that the order at which the invalidate method is used matters, for example if the method is defined after the UDP it affects then the sequence can complete before invalidation takes place. On the other if you want invalidation to take place first the invalidate method should be defined before the affected UDP.

set_step

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

Syntax

{udp}.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
{my_sequence} = {bull} then {bear} then {bull+} then {bear+}

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

Remarks

Users cannot set a negative value for a step (e.g: {udp}.set_step(-1)), which would instead set the step to 0. Consider that the order at which the set_step method is used matters, if you want to set a step value before the sequence evaluation the set_step method should be defined before the affected UDP.