Sidechair

alert.* constants

Browse the reference

How often alert() may fire: alert.freq_all, alert.freq_once_per_bar and alert.freq_once_per_bar_close.

Try it in the editor

alert.freq_* constants go in the freq argument of alert(). alert.freq_all fires on every call, including several times in one bar. alert.freq_once_per_bar (the default) fires on the first call in a bar, in real time, and ignores later calls in that bar. alert.freq_once_per_bar_close fires only when the bar closes, using the values at the close.

For a signal you act on, alert.freq_once_per_bar_close avoids alerts that fire mid-bar and are gone by the close.

Constants

NameValueDescription
alert.freq_allFire on every call, even several times in one bar.
alert.freq_once_per_barFire on the first call in each bar; the default.
alert.freq_once_per_bar_closeFire only when the bar closes.

Remarks

  • The frequency applies to alert() calls. alertcondition does not take a freq; frequency is chosen when the alert is created on the chart.
  • Frequency is a property of one alert() call. Two calls on the same bar with alert.freq_once_per_bar send one message, because only the first call in a bar is counted.

Example

Pine ScriptAlert on a confirmed crossOpen in editor
//@version=6
indicator("Alert frequency", overlay = true)
fast = ta.ema(close, 12)
slow = ta.ema(close, 26)
cross = ta.crossover(fast, slow)
if cross
    alert("Fast crossed above slow on " + syminfo.ticker, alert.freq_once_per_bar_close)
plot(fast, "Fast", color.blue)
plot(slow, "Slow", color.orange)
plotshape(cross, "Cross", shape.triangleup, location.belowbar, color.green)

See also

Runs on Sidechair