Skip to content

alertcondition() - Pine Script Function

alertcondition() registers a named alert in the Create Alert dialog. It does not trigger alerts by itself; instead, it defines the condition, title, and optional message that the user can enable. Think of it as publishing alert signals from your script.

alertcondition(condition, title, message) → void
NameTypeDescription
conditionseries boolBoolean series that determines when the alert fires (true → trigger).
titleconst stringLabel shown in the Create Alert dialog.
messageconst stringOptional default message for the alert (can be edited by the user).
  • Each call counts as an output series toward the script’s plot limit.
  • Use clear titles—this is what users see when choosing the alert condition.
  • Combine with placeholders (e.g., {{close}}) in the message to include dynamic values.
//@version=5
indicator("alertcondition demo", overlay=true)
isGreen = close > open
alertcondition(
condition = isGreen,
title = "Green candle",
message = "Close {{close}} is above open {{open}}.")
plotshape(isGreen, title="Green bar", style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0))