Questions › Guides

NinjaTrader 8: send alerts to a webhook that get retried

Short answer: NinjaTrader 8 has no webhook option for alerts. A NinjaScript indicator or strategy can post one in C#, but plain code sends once: if your server is slow or down, the alert is lost, and a blocking call holds up your chart. Send in the background, only on realtime bars, to something that retries.

Why alerts get lost

  1. No retry. A plain web request sends once. A server restart or a network blip loses that alert.
  2. Blocking calls. Sending inside OnBarUpdate on the main thread holds up your script while it waits.
  3. Historical bars. Without a State.Realtime check, loading a chart fires a burst of old alerts.
  4. Wrong URL. A 401 means the token in the URL is wrong. Repeating it won't help, so our snippet stops.

Set it up with HoldAlarms

  1. Start a trial and copy the webhook URL from your dashboard. It looks like https://api.holdalarms.com/hook/<your token>.
  2. Add your own endpoint as a destination in HoldAlarms.
  3. Copy HoldAlarmsClient.cs and HoldAlarmsNotifier.cs into Documents\NinjaTrader 8\bin\Custom\Indicators and press F5 in the NinjaScript Editor.
  4. Add HoldAlarmsNotifier to a chart, paste the URL and check Recent alerts on your dashboard.
  5. In your own code, call HoldAlarms.HoldAlarmsClient.AlertAsync(...) or SendAsync(url, body).

Full reference: Docs: NinjaTrader setup.

What HoldAlarms does

We answer NinjaTrader with HTTP 200 once the alert is queued, then deliver it to your endpoint in the background. Your endpoint gets 10 seconds per attempt. If it fails, we retry up to 5 times, 2 to 60 seconds apart (permanent errors such as 401 or 403 aren't retried). Retries finish within about 3 minutes, or up to about 6 if your server asks for longer waits with Retry-After. After that the alert is parked in a dead-letter queue and you get an email.

Two honest limits: we add a hop, so HoldAlarms doesn't cut latency; and a delivered alert means your endpoint accepted it, not that your app finished processing it. Starter is €19/mo and Ops €49/mo.

Questions

Does NinjaTrader 8 have built-in webhooks?

No. NinjaTrader 8 alerts can play a sound, show a pop-up or send an email, but not post to a webhook. A NinjaScript indicator or strategy can send one in C#.

Will sending a webhook freeze my chart?

Not with our free snippet. HoldAlarmsClient sends on a background thread, so OnBarUpdate carries on while the request runs.

Why did I get old alerts when I loaded a chart?

Your script ran on historical bars. Only send when State is State.Realtime, as the example indicator does.

Does NinjaTrader retry a failed webhook?

NinjaTrader has no webhook of its own, so nothing retries unless your code does. Our snippet tries twice on a network error or 5xx. HoldAlarms then retries your own endpoint up to 5 times.

Does HoldAlarms reduce latency?

No. HoldAlarms adds a hop, so each alert reaches your endpoint slightly later than it would directly. What it gives you is an answer to NinjaTrader as soon as the alert is queued, and 5 retries to your endpoint.

More guides

HoldAlarms is not affiliated with NinjaTrader. NinjaTrader is a trademark of its owner.