sound
Short sounds a script can play on the live bar. Built-in sounds only (made in the browser, no file is loaded); the viewer controls volume and mute.
#Functions
#sound.playfunction
Plays a built-in sound (sound.) or one of the viewer's own clips (sound.custom1 to sound.custom3) when the newest bar runs live. Never on history; at most one sound per run; the page limits how often sounds play. Anything that is not a sound. id is ignored.
sound.play(id: string, { volume?: float = 0.6, freq?: const alert_freq = alert.freq_once_per_bar })| Parameter | Type | Description |
|---|---|---|
id | string | The sound: sound.chime, sound.ping, ... or sound.custom1 to sound.custom3. |
volume | floatdefault 0.6 | From 0 (silent) to 1; the viewer's own volume applies on top. |
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))) {
sound.play(sound.chime)
}Since ChartScript 1
#Constants
| Name | Type | Description |
|---|---|---|
sound.alarm | string | Three short beeps. |
sound.chime | string | Two soft bell notes. |
sound.coin | string | Two bright notes. |
sound.custom1 | string | The viewer's own clip number 1 (picked in their Settings, kept in their browser); a plain ping when the slot is empty. |
sound.custom2 | string | The viewer's own clip number 2 (picked in their Settings, kept in their browser); a plain ping when the slot is empty. |
sound.custom3 | string | The viewer's own clip number 3 (picked in their Settings, kept in their browser); a plain ping when the slot is empty. |
sound.fall | string | Three notes going down. |
sound.knock | string | Two low knocks. |
sound.ping | string | One short high note. |
sound.pop | string | A short low pop. |
sound.rise | string | Three notes going up. |
sound.thud | string | One deep low note. |
sound.tick | string | A very short click. |