VP Script
Alerts
A script declares what is worth being told about. It does not send anything: delivery belongs to the host, so the same script can drive a browser notification, a Telegram message, or nothing at all.
Declaring one
indicator('Crossover alert') const fast = ta.sma(close, 10)const slow = ta.sma(close, 30) plot(fast)plot(slow) alertcondition(ta.crossover(fast, slow), { title: 'Fast crossed above slow', message: 'The 10 crossed above the 30.',})title is required, because it is the alert’s identity. Two untitled alerts would share a watermark and silence each other.
When it fires
- On closed bars only. There is no intrabar mode, deliberately: a condition that is true mid-bar and false at the close is the classic repainting alert, and it fires exactly when it is least reliable.
- At most once per bar, however many times the chart recomputes.
- Never for history. A new alert arms at the current edge; it does not replay a year of crossovers at you the moment you add it.
- Never on a recompute. Changing an input re-runs the study without re-firing what already happened.
Watermarks are per alert, so adding a second condition does not replay the first one’s history.
Writing a condition worth receiving
The firing rules stop duplicates, not noise. An alert on close > ma is true on every bar of a trend and will tell you so on every one of them; an alert on ta.crossover(close, ma) tells you when the fact changed. Prefer the edge over the state.