Alert()

View as Markdown

Definition

Generates a visual/audible alert to display in the Alerts Log window.

  1. This method can only be called once the State has reached State.Realtime. Calls to this method in any other State will be silently ignored.
  2. For add-ons, please see the AlertCallback() method.

Method Return Value

This method does not return a value.

Syntax

Alert(string id, Priority priority, string message, string soundLocation, int rearmSeconds, Brush backBrush, Brush foreColor)

Parameters

ParameterDescription
idA string representing a unique id for the alert
prioritySets the precedence of the alert in relation to other alerts. Possible values include: Priority.High, Priority.Low, Priority.Medium
messageA string representing the Alert message
soundLocationA string representing the absolute file path of the .wav file to play
rearmSecondsAn int which sets the number of seconds an alert rearms. Note: If the same alert (identified by the id parameter) is called within a time window of the time of last alert + rearmSeconds, the alert will be ignored
backBrushSets the background color of the Alerts window row for this alert when triggered (reference)
foreBrushSets the foreground color of the Alerts window row for this alert when triggered (reference)

You can obtain the default NinjaTrader installation directory to access the sounds folder by using NinjaTrader.Core.Globals.InstallDir property. Please see the example below for usage.

Example

1protected override void OnBarUpdate()
2{
3 // Generate an alert when the RSI value is greater or equal to 20
4 if(RSI(14, 3)[0] >= 20)
5 Alert("myAlert", Priority.High, "Reached threshold", NinjaTrader.Core.Globals.InstallDir+"\\sounds\\Alert1.wav", 10, Brushes.Black, Brushes.Yellow);
6}