Script alerts

You can configure a “script alert” on a Pine script when code contains calls to the `alert()` function. From the chart, create an alert using the “Create Alert” dialog box and select that indicator or strategy in the “Condition” field.

Contrary to other types of alerts, the triggering frequency and the message sent with script alerts are controlled by the `alert()` function calls in the script - not through the “Create Alert” dialog box. Script alerts on indicators will trigger when the conditions used with the script’s `alert()` function calls are met. Script alerts on strategies allow for the inclusion of order fill events, `alert()` function call events, or both.

In order to create a script alert on an indicator, select the script in the “Create Alert” dialog box’s “Condition” field, then the “Any alert() function call” option (the first item in the list).

To create a script alert for a strategy, select the strategy in the “Create Alert” dialog box’s “Condition” field, then select one of the following options:

  • “Order fills and alert() function calls”: the created alerts will trigger on order fills and `alert()` events.
  • “Order fills only”: the alert only triggers on order fills, like an ordinary strategy alert.
  • “alert() function calls only”: the alert only triggers on `alert()` events, like a script alert on an indicator will.

As is the case with other types of alerts, there are limitations on the triggering frequency: if a script alert triggers more than 15 times in 3 minutes, it automatically stops.

More information about using the `alert()` function in scripts can be found in the Pine Reference Manual and the Pine User Manual.