Alerts and popups
An indicator written in XFlow Script can raise an alert, and you do not write a single line of alert code for it. Open the indicator settings, go to the Alert tab, and turn it on. Choose a sound, and leave the popup on to get a dismissable popup in the middle of the screen; a short notification is shown either way. The popup is titled with the name your script gives itself in indicator().
- It fires on a NEW marker from plot.marker, or a NEW zone from plot.zone, or both. Those are the two channels the alert watches, so the way to make a condition alertable is to give it its own plot.marker or plot.zone call site.
- A marker alerts when its bar is new. A zone alerts once the bar that created it has closed, so it states the zone it ends up with rather than one still moving.
- Nothing that was already on the chart when you turned the alert on fires, and history loaded later does not fire either. Each marker or zone fires once.
- A zone whose high equals its low is drawn as a line and does not raise an alert. Give it some height, or add a marker.
- Lines, dots, text, boxes, labels and profiles never raise alerts.
let squeeze: float = ta.stdev(close, 20) / ta.sma(close, 20) * 100
let broke_out: bool = ta.crossover(squeeze, ta.sma(squeeze, 50) * 1.5)
plot.marker(broke_out, high, "#F59E0B", "triangle", "above", 12, 4)