# Swap-Protect

At the configured time(s), the EA attempts to **flatten profitable exposure** to reduce swap costs and avoid widened spreads:

* If **account floating P/L > 0** at trigger time ⇒ **close all open trades** (profitable or not).
* If **account floating P/L ≤ 0** ⇒ **close only profitable trades**, keep losing ones open.

Evaluated using **broker server time** (Market Watch). Applies to EA-managed positions.

{% hint style="info" %}

### Input format

A semicolon-separated schedule of `Key=Time` pairs.

**Accepted keys**

* `All` — applies every day unless a day-specific key overrides it.
* `Mon`, `Tue`, `Wed`, `Thu`, `Fri`, `Sat`, `Sun` — day-specific overrides.
* `Triple` — applies on your broker’s **triple-swap day** (commonly Wednesday for FX; broker-dependent).

**Time format**

* `HH` or `HH:MM` (24-hour). Examples: `21`, `20:30`, `20:45`.

**Examples**

* Minimal: `All=21; Fri=20:30`
* Full custom: `All=20:50; Mon=20:40; Tue=19:00; Wed=20:40; Thu=20:40; Fri=20:40; Triple=20:45`
  {% endhint %}

{% hint style="info" %}

### Precedence & triggering

1. **Triple** applies only on the broker’s triple-swap day.
2. **Day key** (e.g., `Fri`) overrides `All` for that day.
3. If **multiple rules** match the same day (e.g., `Fri` **and** `Triple` on Wednesday):
   * The EA **fires at the earliest time** among applicable rules.
4. One trigger per day; after firing, it won’t re-trigger until the next day.
   {% endhint %}

{% hint style="info" %}

### Close logic (at the trigger time)

1. Compute **account floating P/L** across EA-managed positions.
2. **If > 0:** send close requests for **all** open positions.
3. **If ≤ 0:** send close requests for **profitable positions only**; leave losing ones open.
4. Execution is subject to **market liquidity, spreads, and slippage** at rollover.

> Floating P/L includes commission and current swap to that moment (swap typically posts at rollover).
> {% endhint %}

{% hint style="success" %}

### Why use it

* **Reduce swap drag** by exiting before rollover, especially on **Triple** days.
* **Protect profits** when spreads often widen around end-of-day.
* Enforces **discipline** without manual intervention on VPS/off-hours.
  {% endhint %}

{% hint style="warning" %}

### Why not

* You may **exit winners too early** and miss continued moves.
* **Widened spreads** at rollover can cause slippage on exits.
* If overall P/L ≤ 0, losing trades **remain open** (by design).
  {% endhint %}

{% hint style="info" %}

### Keep in mind

* **Broker server time rules.** Confirm your broker’s rollover and **triple-swap day**.
* **Symbol coverage.** The feature acts only on positions the EA manages (check magic/symbol scope).
* **Pending orders.** This setting **does not cancel** pendings; consider a separate “cancel pendings at rollover” option if available.
* **Interaction with loss limits.** A Daily/Weekly Loss Limit may pause trading earlier; whichever condition triggers first wins.
* **Backtests.** Tester aggregates ticks around rollover; verify behavior in **visual mode**.
  {% endhint %}

That’s it—clean, rule-based exits to limit swap costs and rollover surprises.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://smartchoise.gitbook.io/smartchoise-manual/options/account-protection/swap-protect.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
