Exciting Update: Version 1.0.1 is now available, introducing the high-performance BacktestX Custom Script Editor. Read more
Version: 1.0.1

Custom Alerts & Webhooks

The ctx.alert() function allows you to fire custom notifications, sounds, and outgoing webhooks when a specific technical condition is met in your script.

Triggering Alerts

Alerts are evaluated dynamically on the current bar. The engine automatically handles deduplication so that alerts do not spam the console during historical backtests.

// Trigger an alert when RSI dips below 30
const rsi = ctx.ta.rsi(ctx.bars.map(b => b.close), 14);
const isOversold = rsi[ctx.bars.length - 1] < 30;

ctx.alert("RSI is Oversold! Buy Signal generated.", isOversold);

Webhook Integration

If you connect a Webhook URL in your terminal settings, any call to ctx.alert(message, true) will dispatch a JSON payload to your server:

{
  "symbol": "BTCUSD",
  "timeframe": "15m",
  "message": "RSI is Oversold! Buy Signal generated.",
  "price": 64500.50,
  "timestamp": 1721245000000
}