# Equity Guard

> What Equity Guard's floors, daily loss limits and profit targets do, and how the followers it pauses, trades it skips and copies it closes show in the API.

Equity Guard watches an account's equity and acts the moment it crosses a line you set. Depending on the action you pick, it emails you, pauses copying as well, or also closes every position. You set it up in the app, on the account's **Equity Guard** tab. The API can't read or change guards yet, but it shows what a guard does to copying: in the [follower status](/docs/followers#status) and in [copy events](/docs/events).

For what each rule does on a prop firm account, with a worked example, see [how Equity Guard works](/equity-guard).

## Rules [#rules]

A guard has up to three rules. Each one is an amount in the account's currency or a percentage of the starting balance.

| Rule             | Acts when                        | As a percentage                                |
| ---------------- | -------------------------------- | ---------------------------------------------- |
| Equity floor     | Equity falls to the line         | Below the starting balance: a maximum drawdown |
| Daily loss limit | The day's loss reaches the limit | Of the starting balance, per day               |
| Profit target    | Equity rises to the line         | Above the starting balance                     |

Each rule has its own action:

| Action                 | What it does                                                |
| ---------------------- | ----------------------------------------------------------- |
| Alert                  | Emails you                                                  |
| Alert and pause        | Also pauses copying to and from the account                 |
| Alert, pause and close | Also closes every position and pending order on the account |

* **The starting balance** is what percentages are measured from. Equity Guard reads it from the first deposit in the account's history, and you can change it.
* **The day** for the daily loss limit starts at the broker's midnight, on the server time its MetaTrader charts show, or at a time and time zone you pick. The limit counts down from the balance when the day began, or from the higher of balance and equity then.
* **Each rule acts once.** After it has fired, it waits until you resume the guard in the app. A daily loss limit can also let go by itself when the next day starts.
* **Closing** happens at the market price, and Equity Guard keeps trying until the account is flat. In a fast market a fill can land past the line, so set your lines a little inside your firm's limits.
* **An account connected with its investor password** can't trade, so its guard only alerts.

## Paused followers [#paused-followers]

A pause holds back new copies. Copies that are already open stay open, and still follow the master's closes and changes. Which followers are held back depends on whose guard paused:

* **A follower's own guard** pauses copying to that follower only.
* **A master's guard** pauses copying from that master, to every follower of every copier that uses it.

While Equity Guard holds a follower back, its `status` says so. Its `is_active` stays `true`. That field is your own pause, and the guard doesn't change it.

```json
{
  "object": "follower",
  "is_active": true,
  "status": {
    "state": "paused",
    "message": "Paused by Equity Guard.",
    "open_copies": 0,
    "engine_online": true
  }
}
```

So if a follower's `state` is `paused` while both the follower and its copier have `is_active: true`, Equity Guard has paused it. When the guard is resumed, or a daily loss limit's next day starts, `state` goes back to `copying` within seconds.

TypeScript:

```ts
const copier = await att("GET", "/copiers/c7d1e5f2-3a4b-4c6d-8e9f-0a1b2c3d4e5f");
for (const follower of copier.followers) {
  const held = copier.is_active && follower.is_active && follower.status?.state === "paused";
  if (held) console.log(`${follower.account.name}: paused by Equity Guard`);
}
```

Python:

```python
copier = att("GET", "/copiers/c7d1e5f2-3a4b-4c6d-8e9f-0a1b2c3d4e5f")
for follower in copier["followers"]:
    status = follower["status"] or {}
    held = copier["is_active"] and follower["is_active"] and status.get("state") == "paused"
    if held:
        print(f"{follower['account']['name']}: paused by Equity Guard")
```

The examples use the `att` helper from the [Quickstart](/docs/quickstart#2-export-the-key).

## Skipped trades [#skipped-trades]

Trades the master opens while a follower is held back aren't copied, not even after the guard is resumed. Pending orders it places then aren't placed on the follower either. Each such trade is a `skip` [copy event](/docs/events) with the message `Opened while Equity Guard had copying paused.`

## Closed copies [#closed-copies]

When a guard closes positions, the copies involved close too. Each closed copy is a `close` copy event:

* **On a master,** the master's positions close, and the copier closes their copies, as it does for any close on the master.
* **On a follower,** its copies are closed on the account directly. Their `close` events say `Closed on the follower account (stop loss, take profit, by hand or by Equity Guard).`
