Skip to content
Nexus Prop LLC

NexuScript 1.5

Alerts and output

Telling the trader something happened.

alert

functionNexuScript 1.0

Raises an alert on this bar.

Syntax

alert(text::String, title::String = automatic)

Parameters

NameTypeDefaultDescription
textStringrequiredThe message the trader sees. Put values in with $(...).
titleStringautomaticA 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")
end

See also

markerprintif

functionNexuScript 1.0

Writes a line to the script window, handy for checking values.

Syntax

print(value::Any...)

Parameters

NameTypeDefaultDescription
valueAnyany numberrequiredAny 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

See also

alerttablestring