alert reference
Declared alerts and their triggers.
Declare an alert at top level with alert name = alert(title: ...) and fire it from a handler with name.trigger(). Alerts fire on live data only.
Functions
alert
alert(title: string, description: string = "", onClose: bool = false, payload: Type = null) -> AlertDeclares an alert that the script can trigger.
Use this directly in an alert declaration. Keep the declaration’s name
stable; it identifies the alert.
titleis the required display name.descriptionadds optional help text. Both must be string literals.onClosedefaults to false, allowing the alert to fire on the first trigger during a bar. Set it to true to fire only when a bar is confirmed.payloadoptionally names a declared record type. Its fields can be string, int, float, bool, or nullable versions of those types. Omit it or use null for an alert with no payload.
Alerts fire only on live data, at most once per bar for each declaration.
| Parameter | Type |
|---|---|
title | string |
description | string |
onClose | bool |
payload | AlertPayload? |
Returns Alert
Available in Setup only: declarations, setup and state initialisers.
Methods
alert.trigger
alert.trigger(payload: P = null) -> voidTriggers an alert on live data.
Call this on an alert you declared, or an alias of that alert, from a handler or a function called by a handler.
For an alert with a payload, pass one record of its declared type. For an alert without a payload, pass no argument. The call returns no value.
Each alert can fire at most once per bar. Historical replay evaluates the
arguments but does not send an alert. With onClose: true, triggers during a
forming bar do not send an alert either.
| Parameter | Type |
|---|---|
payload | AlertPayload? |
Available in Handlers and functions called from handlers.