# Alerts that know when to stay quiet.

> An alert watches for something and sends you a message. In AlgoBarsX the alert also carries its own rules: how often to check, whether it may repeat, how long to wait, and when to stop.

Source: https://algobarsx.com/alerts/

## An alert that watches your account.

This one checks every minute. It tells you when today's loss passes 2% of the account, or when your margin level gets low. Then it waits 4 hours before it may speak again.

- `check` says how often to look
- `repeat` and `cooldown` stop it from nagging you
- The message can include live numbers

```algobarsx
alert "Daily risk guard"
    check: every 1m
    repeat: every time
    cooldown: 4h

when history.today.pnl < -(2% of account.balance) or account.margin_level < 150%:
    notify "Daily P&L {history.today.pnl:$0.00}, margin level {account.margin_level:0}%"
```

The compiler reads it back:

> Daily risk guard is an alert that checks every 1 minute, can fire every time its condition is met and waits 4 hours between alerts.

> When today's closed profit or loss is below minus 2% of the account balance or the margin level is below 150%, it sends the notification "Daily P&L {history.today.pnl:$0.00}, margin level {account.margin_level:0}%".

## Watch anything you can describe.

- **Price and indicators** A cross, a breakout, a divergence, a squeeze. If you can write the condition, you can be told about it. [See the example](https://algobarsx.com/docs/ex-12-rsi-divergence-alert/)
- **Your own account** Balance, equity, margin level, open trades and today's result are all values an alert can read. [See the example](https://algobarsx.com/docs/ex-23-margin-exposure-alert/)
- **Inside the bar** Check every minute, not just at the close, for fast moves and spikes. [See the example](https://algobarsx.com/docs/ex-41-intrabar-spike-alert/)
- **Sessions and gaps** Know when a session opens with a gap, or when a market wakes up. [See the example](https://algobarsx.com/docs/ex-45-tokyo-open-gap-alert/)
- **Marks on the chart** An alert can mark the spot where it fired, so you can look back later. [Read more](https://algobarsx.com/docs/writing-an-alert/)
- **Test before you trust** Run an alert over past prices. See every message it would have sent, and the ones its own rules held back. [Read more](https://algobarsx.com/docs/why-alert-quiet/)

> **Where messages go.** In this version, alert messages arrive inside the AlgoBars app and in AI chat.

## Good questions.

**Why did my alert only fire once?** Its own settings decide. The default is once per bar. `cooldown` sets the shortest gap between messages and `expires` turns the alert off.

**Do I need to know how to code?** No. The code reads like plain words, it reads itself back in English, and you can type your idea in plain English and press Convert to AlgoBarsX.

**Is an alert a trade signal?** No. An alert tells you that something you described has happened. It is not advice, and what you do next is up to you.

## Important

Trading is risky and you can lose money. AlgoBars is software, not a broker or an adviser. Backtests are hypothetical and leave out spread, fees, swaps and slippage. AlgoBarsX is in beta.
