Write
Alerts in scripts
What alert() and alertcondition() do on Tradequix today, and how they differ from the server price alerts that fire with the tab closed.
There are two different things called alerts on Tradequix. Knowing which is which saves confusion.
| Script alerts | Price alerts | |
|---|---|---|
| Created by | alert() / alertcondition() in Pine | The alert button on the chart |
| Evaluated | Where the script runs, while the chart is open | On the server, all the time |
| You see them | In the Pine editor's console | As a notification and an email |
| Fire with the tab closed | No | Yes |
Script alerts#
alert(message) emits an event when it is called. alertcondition(condition, title, message) declares a condition that can be alerted on. Both run and are captured; the events appear in the console of the Pine editor, so you can see exactly when your logic would have fired.
//@version=6indicator("Breakout alert", overlay = true)hi = ta.highest(high, 20)[1]plot(hi, "20-bar high", color = color.orange, style = plot.style_stepline)breakout = ta.crossover(close, hi)plotshape(breakout, "Breakout", style = shape.arrowup, location = location.belowbar, color = color.teal, size = size.small)alertcondition(breakout, "Breakout", "Close broke the 20-bar high")if breakout alert("Breakout at " + str.tostring(close, format.mintick), alert.freq_once_per_bar_close)Use them to check your signal logic while building a script.
Price alerts#
Price alerts are set from the chart's alert button on a level: crossing, greater than, less than, entering or leaving a range, and more. They are checked by the server on every bar, so they fire whether or not your chart is open, and reach you as an in-app notification and an email. Conditions based on an indicator's value are not available yet.