Alert conditions
The annotation function
alertcondition
allows you to create custom alert conditions in Pine indicators. One
script may have one or more alertcondition
calls. The function has the
following signature:
alertcondition(condition, title, message)
condition
true
or false
) values that is used for
alert. true
means that the alert condition is met, alert should
trigger. false
means that the alert condition is not met, alert
should not trigger. It is a required argument.
title
message
Here is example of creating an alert condition:
The function creates alert condition that is available in Create Alert
dialog. Please note, that alertcondition does NOT start alerts
programmatically, it only gives you opportunity to create a custom
condition for Create Alert dialog. Alerts must be still started
manually. Also, an alert created with a custom alertcondition
in Pine
code is not displayed on a chart.
To create an alert based on an alertcondition, one should apply a Pine indicator with an alertcontidion to the current chart, open the Create Alert dialog, select the applied Pine code as main condition for the alert and choose the specific alert condition (implemented in the code itself).
When alert fires, you’ll see the message: