# Daily risk guard

> 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.

Source: https://algobarsx.com/docs/ex-06-daily-risk-guard/

```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}%"
```
What this script says

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}%".
