Marks, finished bars and alerts

mark() and alert() on yes/no conditions; "and closed" for finished bars.

For AI tools: this page as Markdown · the whole language in one file

1name("Crossovers", where = chart)2 3fast = ema(close, 9)4slow = ema(close, 21)5plot(fast)6plot(slow)7mark(crosses_above(fast, slow) and closed, "B", where = below)8mark(crosses_below(fast, slow) and closed, "S", where = above, color = orange)9alert(crosses_above(fast, slow), "Fast crossed above slow at {close}")

A mark can also be a label at a price, with values in its text:

Swing highs and lows, labelled with their price

1name("Pivot labels", where = chart)2 3ph = pivot_high(high, 8, 8)4pl = pivot_low(low, 8, 8)5mark(not empty(ph), "{ph}", at = ph, shape = dot, color = orange, offset = -8)6mark(not empty(pl), "{pl}", at = pl, where = below, shape = dot, color = teal, offset = -8)

The newest bar is still forming: its close moves with every trade, so a condition on it can be true one moment and false the next. closed is true on finished bars and false on the forming one. Add and closed so a mark never appears and then vanishes.

An alert fires once, when a bar closes with its condition true (never for the history loaded with the chart, never in bar replay), while a chart running the script is open. It follows your alert settings: quiet hours, desktop notifications and sound. {name} puts a value of the script in the message. The editor's Alerts tab lists what fired.

See also: mark, alert, closed