# Margin and exposure

> Margin and exposure is an alert that checks every 5 minutes and fires only once.

Source: https://algobarsx.com/docs/ex-23-margin-exposure-alert/

```algobarsx
alert "Margin and exposure"
    check: every 5m
    repeat: once
    expires: 30d

when account.free_margin < 20% of account.equity or positions.len >= 8:
    notify "Free margin {account.free_margin:$0} with {positions.len} open positions"
```
What this script says

Margin and exposure is an alert that checks every 5 minutes and fires only once.

When free margin is below 20% of equity or the number of open positions is at or above 8, it sends the notification "Free margin {account.free_margin:$0} with {positions.len} open positions".
