Skip to main content
A script can offer a condition for an alert (alertcondition) or raise an alert from its own logic (alert). Neither takes a frequency argument.

alert

Call alert where the event happens. Its message may be built from data. On historical bars it does nothing.
alert returns no value (x = alert("a") is refused: Cannot assign void value.). On a forming bar the bar’s one alert is raised on the first tick that asks for it, with that tick’s price. To alert on the closed bar, write if barstate.isconfirmed and condition (see How to avoid a result that changes after the bar closes).

alertcondition

Declare the condition once, at the top level, with a fixed title and message:
The condition must be boolean (alertcondition(close) is refused: The condition argument of alertcondition() must be a boolean series.) and the message is const: a series string there (str.tostring(close)) is refused as in qualifiers. Inside an if, alertcondition is refused like plot: alertcondition() must be called in the global scope. Put the test in the condition argument. Use alert when the message or the moment depends on what the script worked out on this bar. Use alertcondition for a named condition that the user turns into an alert. For delivery, see Webhooks.