Sidechair

alertcondition()

Browse the reference

Declares a named alert condition that can be picked when creating an alert on an indicator.

Try it in the editor

alertcondition(condition, title, message) adds an entry to the alert dialog for the script. It does not fire anything by itself; you create an alert from it and the alert fires on each bar where condition is true.

The message may include placeholders in double braces, such as {{ticker}}, {{close}} and {{interval}}, which are filled in when the alert fires.

Syntax

Pine Script
alertcondition(condition: series bool, title: const string (optional), message: const string (optional)) -> void

Arguments

NameTypeDefaultDescription
conditionseries boolrequiredThe series bool that triggers the alert on bars where it is true.
titleconst stringan empty titleThe name that appears in the alert dialog.
messageconst stringan empty messageThe text sent when the alert fires. Placeholders such as {{ticker}} and {{close}} are replaced.

Returns

Nothing.

Remarks

  • It must be called at the top level of an indicator, not inside an if, a loop or a function, and it is not available in strategies. Use alert() when you need either.
  • title and message must be constant text. They cannot depend on values calculated per bar.
  • Each alertcondition() adds one entry to the script's alert list, so declare one per signal you want to be able to pick. The same script can offer a long and a short condition side by side.

Example

Pine ScriptAlert condition on RSIOpen in editor
//@version=6
indicator("RSI condition")
r = ta.rsi(close, 14)
plot(r, "RSI")
hline(70)
hline(30)
alertcondition(ta.crossover(r, 70), "RSI above 70", "{{ticker}} RSI crossed above 70")

See also

Runs on Sidechair