> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# AlertCallback()

## Definition

Creates an alert event to be raised specified by a string "id" and a corresponding .wav file will be played matching the "soundLocation" parameter. Once an alert has triggered, its message is reflected in the "Alerts Log" window based on the background and foreground brushes provided in the callback.

1. If the AlertCallback() method is called again with the same string "id" parameter before the provided "rearmSeconds" duration has passed, the alert event will be reset based on the new "rearmSeconds" parameter provided. Doing so could consequently cause an alert to be reset inadvertently, in which case you should pass a "rearmSeconds" parameter of "0" to ensure the specified alert event is always raised.
2. The AlertCallback() method is the same core function used by the simpler [Alert()](/developer/desktop-sdk/references/common/alert-debug-share/alert) method which can alternatively be used with NinjaScript indicators and strategies. The AlertCallback() was exposed for use with Add-ons or other more advance use cases.
3. Providing a "rearmSeconds" parameter greater than "0" will add the matching alert id to a rearmed state, which only allows the alert to be reissued after the specified time interval in seconds has lapsed. You can reset an alert's rearm parameter by using the [ResetAlertRearmById()](/developer/desktop-sdk/references/common/alert-debug-share/rearmalert).

## Method Return Value

This method does not return a value.

## Syntax

`NinjaTrader.NinjaScript.Alert.AlertCallback(Instrument instrument, object source, string id, DateTime time, Priority priority, string message, string soundLocation, Brush backBrush, Brush foreBrush, int rearmSeconds)`

An "id" parameter MUST be provided otherwise a null argument exception will be generated

## Parameters

| Parameter     | Description                                                                                                                                                                                                               |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| instrument    | An [Instrument](/developer/desktop-sdk/references/common/instrument) object associated with the alert.                                                                                                                    |
| source        | A generic object type which created the alert (e.g. "this")                                                                                                                                                               |
| id            | A string representing a unique id for the alert                                                                                                                                                                           |
| time          | The DateTime representing the time associated with the alert                                                                                                                                                              |
| priority      | Sets the precedence of the alert in relation to other alerts. Any one of the following values: Priority.High, Priority.Low, Priority.Medium                                                                               |
| message       | A string representing the Alert message                                                                                                                                                                                   |
| soundLocation | A string representing the absolute file path of the .wav file to play.                                                                                                                                                    |
| backBrush     | Sets the background color of the Alerts window row for this alert when triggered                                                                                                                                          |
| foreBrush     | Sets the foreground color of the Alerts window row for this alert when triggered                                                                                                                                          |
| rearmSeconds  | An int which sets the number of seconds an alert will rearm. 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. |

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.

## Examples

```csharp
NinjaTrader.NinjaScript.Alert.AlertCallback(NinjaTrader.Cbi.Instrument.GetInstrument("MSFT"), this, "someId", NinjaTrader.Core.Globals.Now, Priority.High, "message", NinjaTrader.Core.Globals.InstallDir+@"\sounds\Alert1.wav", new SolidColorBrush(Colors.Blue), new SolidColorBrush(Colors.White), 0);
```