alertcondition() - Pine Script Function
alertcondition()
Section titled “alertcondition()”Overview
Section titled “Overview”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.
Syntax
Section titled “Syntax”alertcondition(condition, title, message) → voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
condition | series bool | Boolean series that determines when the alert fires (true → trigger). |
title | const string | Label shown in the Create Alert dialog. |
message | const string | Optional default message for the alert (can be edited by the user). |
Remarks
Section titled “Remarks”- 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.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=5indicator("alertcondition demo", overlay=true)
isGreen = close > openalertcondition( 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))