NexuScript 1.5
Alerts and output
Telling the trader something happened.
Raises an alert on this bar.
Syntax
alert(text::String, title::String = automatic)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
text | String | required | The message the trader sees. Put values in with $(...). |
title | String | automatic | A short name for the alert. Left out, the script's title is used. |
Details
The chart fires an alert once per bar for each title and text, and only on live charts, never while the history loads. The newest 100 alerts of a run are kept. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.
Missing values
A missing number written into the text shows as missing.
Live and historical bars
Alerts reach the trader from live bars only. Alerts raised on past bars are recorded but not fired.
Example
let up = ta.crossover(close, ta.sma(close, 20))
if up
alert("Close crossed above its 20 bar average at $(close)", title = "Cross up")
endSee also
Writes a line to the script window, handy for checking values.
Syntax
print(value::Any...)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
value | Anyany number | required | Any number of values of any type, written with a space between them. |
Details
Only the first 50 lines of a run are written; after that a note says more lines were dropped. It is an effect: it may run anywhere inside on bar, also inside an if, a loop or a function called from on bar, but not in setup or inside a higher block (NS230). A bar that runs again first loses everything it drew.
Missing values
A missing number is written as missing.
Example
if bar.last
print("Last close", close, "on bar", bar.index)
end