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 = "" })| Parameter | Type | Description |
|---|---|---|
condition | bool | The condition. |
title | const string | The name shown in the settings, legend and data window. |
message | const stringdefault "" | The text. |
Example
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 })| Parameter | Type | Description |
|---|---|---|
message | string | The text. |
freq | const alert_freqdefault alert.freq_once_per_bar | How often it may fire: alert.freq_once_per_bar (default), _once_per_bar_close or _all. |
Example
if (ta.crossover(close, ta.sma(close, 20))) {
alert.send("Cross at " + str.tostring(close))
}Since ChartScript 1
#Constants
| Name | Type | Description |
|---|---|---|
alert.freq_all | alert_freq | Fire on every run (every tick of the live bar). |
alert.freq_once_per_bar | alert_freq | Fire at most once per bar (can fire on a bar that later reverses). |
alert.freq_once_per_bar_close | alert_freq | Fire at most once per bar, when it closes. |
#Not supported
#alertfunction
Not supported in ChartScript.
Use alert.send(message, freq).
Since ChartScript 1