## 6. Protection System

Zyra Guardian Pro includes multiple layers of protection to help preserve your capital, reduce exposure to bad conditions, and lock in profits over time. These tools work independently from your broker's stop loss or margin calls and are designed to make the EA more resilient.

The setting Action to apply when exiting a user-defined session offers three behaviors: Close forces an immediate exit of all trades when protection limits are hit, Pause only suspends fresh entries while letting existing positions manage themselves, and Continue keeps normal management active but blocks new orders. These options shape the trading experience: an aggressive mode like Close secures capital instantly at the cost of interruptions, while Pause or Continue let the strategy breathe without abandoning open positions.

Daily suspension: when the daily limits are breached, the internal flag `g_tradingSuspendedForDay` flips to `true`. The EA stops opening new positions until the next daily reset. If Close all positions when the daily limit is reached is enabled, the suspension also forces every remaining position to close in order to enforce the circuit breaker.

### Weekly Suspension and Weekly Auto-Close

Weekly limits (Maximum realised weekly loss allowed, Weekly profit target, Calculation mode for the weekly PnL) follow the same logic as their daily counterparts. Once the week’s cumulative performance crosses a threshold, the dedicated flag `g_tradingSuspendedForWeek` triggers an extended pause: no new trades are allowed until the Monday reset. With Close all positions when the weekly limit is reached enabled, Zyra also closes every open position before switching into suspension, locking the weekly result in place.

Head to Money Management for a complete breakdown of the parameters and examples that compare them with the daily limits.

Interaction with the session exit action: regardless of the time horizon (daily or weekly), the selected mode (Close, Pause, Continue) dictates the exact reaction. Close forces liquidation, Pause blocks fresh entries, and Continue lets ongoing management run while still preventing new orders. Combining Close all positions when the weekly limit is reached with Pause, for example, guarantees that Zyra closes trades at the weekly breach and then remains blocked until the next week without abandoning the current basket management.

Capital Panel: the CapitalPanel now displays a weekly status in addition to the daily line. Messages such as “Weekly limit reached” (red) or “Weekly target hit” (green) instantly confirm whether the circuit breaker is active. The panel also shows whether the automatic closure occurred, making it easy to confirm that Close all positions when the weekly limit is reached triggered as expected.

### CapitalPanel

The CapitalPanel appears in the upper-left corner of the chart and summarizes the session status. The first line (white) shows the current session and the countdown to the next reset. The next line (green or red) displays cumulative daily PnL. Finally, a yellow alert line highlights whether trading is suspended or resumed (for example, "Trading paused"). Keeping an eye on this panel instantly reveals whether the session is active, whether a drawdown is blocking new entries, and if daily performance stays within the defined limits.

### 1. Global Stop Loss

- SL Mode: You can choose how the global stop loss is triggered:
  - `SLPourcent`: The EA will close all trades if the floating (unrealized) loss exceeds a percentage of the allocated capital.
  - `SLByLot`: The EA will close all trades when the floating loss reaches a specific dollar value per 0.01 lot.
- Global Stop %: (Only used if `SLPourcent` is selected) Defines the maximum loss allowed as a percentage of allocated capital before closing all trades.
- SL per 0.01 Lot: (Only used if `SLByLot` is selected) If the loss exceeds this value multiplied by the lot size, all positions are force-closed.
- This protection is based on the floating equity (unrealized losses), not on closed losses.

### 2. Equity Threshold (StopTradingEquity)

- You can define a minimum equity level below which the EA will completely stop opening new trades.
- This allows you to create a safety floor — e.g. if you never want the EA to operate below $950 on a $1000 account.
- Existing trades will still be managed or closed, but no new trades will be opened.

### 3. Spread Filter

- MaxSpread: Zyra checks the current market spread before each trade.
- If the spread is too high (due to volatility or session change), it will avoid entering a position.
- This helps prevent bad entries during slippage or during news events.

### 4. Profit Lock (Capital Locking System)

- This feature creates a virtual "reserve" from your profits that the EA no longer uses for trading.
- ProfitLockPct: Defines what percentage of each profit (TP hit) should be "locked" into the reserve.
- Example: If set to 50%, and a TP generates $10, Zyra keeps $5 aside. This amount is deducted from usable capital.
- This simulates auto-withdrawal: the locked reserve stays in your account but is ignored in further risk calculation.
- ProfitLockInit: Used to initialize the reserve amount if the EA was restarted (e.g., set to $56 to resume from a previous locked state).
- This feature prevents the EA from reusing past gains, helping preserve profits even if the next trades perform poorly.

### 5. Trailing Stop System

- TrailingStartPct: When floating profit reaches this level (based on capital), a trailing mechanism activates.
- TrailingDistancePct: Defines how far behind the current profit the stop will follow.
- This helps secure growing profits while still allowing room for price action.
- For a detailed explanation of both modes (`TrailingByPercent` vs `TrailingPerLot`) and how they interact with `TPTrailing`, refer to the Take Profit & Trailing section of the Parameters page.

### 6. Max Trade Limiter

- MaxTradeOpen: Prevents the EA from opening more than X positions simultaneously.
- This can be used to limit risk exposure during grid expansions or high volatility phases.

### Recommendations

- Always combine Global Stop and Profit Lock for long-term security and compounding.
- Use trailing stops only if you want dynamic exits — otherwise keep it off for simple TP control.
- Set a StopTradingEquity value on funded or challenge accounts to avoid breaching rules.

### Next Step

Proceed to the Indicators section to discover the available signals and how to configure them for your strategy.

### 7. Portfolio Management

- MaxSymbolsAllowed: Limits the number of different symbols Zyra can trade simultaneously. If set to `0`, there is no restriction. For example, setting it to `4` ensures Zyra will never trade more than 4 different symbols at the same time.
- MagicPrefixFilter: Zyra uses this prefix to identify its own trades across all charts. Only positions with a `Magic Number` that starts with this prefix are considered. This allows coordinated management across multiple Zyra instances on the same account.

#### How it works:

Before opening a new trade, Zyra scans all open positions on the account. If the number of different symbols already traded by Zyra (using the Magic Prefix) has reached the limit defined in `MaxSymbolsAllowed`, the EA will not open a new position.

#### Example:

- You are running 10 instances of Zyra (e.g., EURUSD, USDJPY, AUDUSD, etc.)
- `MaxSymbolsAllowed = 4`, `MagicPrefixFilter = "1234"`
- If 4 symbols (e.g., EURUSD, GBPUSD, USDJPY, USDCAD) already have open Zyra positions → a 5th symbol (like AUDUSD) will not be allowed to open trades until one of the 4 closes.

#### Benefits:

- Prevents excessive exposure across too many markets at once.
- Improves control when running multiple pairs with Zyra Guardian Pro.
- Ideal for prop firm setups and multi-symbol strategies.