Skip to content
ChartDeck ChartScript docs Account Open the terminal

alert

Use alert.send(message, freq).

#Functions

#alert.onfunction

A named alert condition that "Create alert" lists.

alert.on(condition: bool, title: const string, { message?: const string = "" })
ParameterTypeDescription
conditionboolThe condition.
titleconst stringThe name shown in the settings, legend and data window.
messageconst stringdefault ""The text.

Example

ChartScriptFragmentOpen in editor
alert.on(ta.crossover(close, ta.sma(close, 20)), "Cross up", "{{ticker}} crossed its SMA")

Since ChartScript 1

#alert.sendfunction

Sends an alert message from the script).

alert.send(message: string, { freq?: const alert_freq = alert.freq_once_per_bar })
ParameterTypeDescription
messagestringThe text.
freqconst alert_freqdefault alert.freq_once_per_barHow often it may fire: alert.freq_once_per_bar (default), _once_per_bar_close or _all.

Example

ChartScriptFragmentOpen in editor
if (ta.crossover(close, ta.sma(close, 20))) {
    alert.send("Cross at " + str.tostring(close))
}

Since ChartScript 1

#Constants

NameTypeDescription
alert.freq_allalert_freqFire on every run (every tick of the live bar).
alert.freq_once_per_baralert_freqFire at most once per bar (can fire on a bar that later reverses).
alert.freq_once_per_bar_closealert_freqFire at most once per bar, when it closes.

#Not supported

#alertfunction

Not supported in ChartScript.

Use alert.send(message, freq).

Since ChartScript 1

The ChartScript documentation is in English for now; translations will follow.