## 4. Trading Strategy

### How Zyra Enters and Manages Trades

Zyra Guardian Pro uses a hybrid approach based on technical signal scoring and an adaptive grid system. It constantly evaluates market conditions using a customizable set of indicators. When favorable conditions are met, the EA opens a position, then uses a dynamic grid logic to manage entries and exits. The goal is to capture profit within structured price movements while avoiding uncontrolled drawdown.

### 1. Entry Signal Scoring

- Each enabled technical indicator (e.g. Ichimoku, RSI, MACD) casts a signal: +1 for BUY, -1 for SELL, 0 for Neutral.
- The sum of all these signals is the current score.
- If the score is equal to or higher than the defined ScoreEntry, a BUY position is opened.
- If the score is equal to or lower than the negative threshold (e.g. -ScoreEntry), a SELL position is opened.
- No trade is executed if the total score remains in the neutral range.
- This scoring system allows flexibility and control: you can combine multiple filters for high-probability entries or simplify it to act on a single indicator.

### 2. Entry Filters & Conditions

- Trading is allowed only when the current market spread is within acceptable bounds (`MaxSpread`).
- EA verifies capital allocation and equity limits before any position is opened.
- Certain indicators require specific market conditions to be valid, such as increasing ATR, confirmed trend from ADX, or breakouts from envelopes.
- You can disable individual signals in the Parameters if you prefer a simplified or focused strategy.

### 3. Consensus Window Workflow

Before Zyra opens the very first grid order, the raw score must pass through the Consensus Window (CW). The window keeps two buffers: W (the weighted vote) and M (the recent momentum of that vote). Only when W and M point in the same direction, and no opposite major indicator resets the window, does the EA authorize an entry.

- Opposite signals are neutralised: if W signals BUY but M turns SELL, the window suspends entries until the buffers align again.
- The Minimum cooldown between new entries and Number of bars to wait after a full grid close before opening new positions timers stack, meaning the EA waits both for the window cooldown and for the post-cycle cooldown before re-arming.
- Maximum number of entries per sliding window limits how many trades can be triggered while the same consensus is active, so the first grid order is the only one that needs CW approval; subsequent grid layers follow the grid logic once the position is live.
- If a major indicator (e.g. Ichimoku or MACD, depending on your parameter choices) fires a strong opposite signal, Reset when a major indicator strongly contradicts the signal empties both W and M to force a fresh confirmation.

Typical log messages help you audit those steps:

    [CW][W] BUY +3.2 | contributors: Ichimoku(+1), MACD(+1), RSI(+1), ADX(0)
    [CW][M] BUY momentum rising | slope=+0.8 | minBars=ok | newEntry=1/2
    [CW] Major veto cleared: no strong opposition detected

In the example above, the first line shows the aggregated vote (W) and which indicators backed it. The second line confirms that the momentum buffer (M) is aligned and that the cooldown requirements are satisfied (1 entry out of 2 allowed in this window). With no veto on the third line, Zyra will proceed to open the initial grid order.

### 4. Grid System

- After an initial trade is opened, the EA may add more trades in the same direction (forming a grid) based on price movement.
- The distance between grid levels is defined by GridStep (in points).
- The size of each new position is multiplied using LotMultiplier, allowing progressive exposure or recovery.
- GridPositif: If enabled, new grid positions are only added if the previous one is in profit, avoiding overexposure in bad conditions.
- GridUniqueTrend: Prevents the EA from opening BUY and SELL grids at the same time, enforcing a unidirectional grid mode.
- This grid logic is NOT blind martingale: it respects defined entry criteria and risk constraints.

### 5. Trade Exit Logic

- The EA constantly monitors the net profit of the grid.
- If the profit exceeds the global take profit threshold (defined in % or in fixed amount), all trades in that direction are closed simultaneously.
- ProfitLock: Optionally, the EA can secure floating profits once a minimum threshold is reached by closing early.
- Trailing Stop: Can dynamically adjust the TP based on real-time profit increases after a target level is reached.
- All trades are also force-closed if the Global Stop Loss is triggered to avoid excessive drawdown.

### 6. Example Workflow

1. EA runs on a chart (e.g., AUDCAD M5).
2. It checks all enabled indicators and calculates the total signal score.
3. If the score passes the entry threshold and all conditions are valid → a trade is opened.
4. If the price moves by at least GridStep → a new trade may be added with increased lot size.
5. Once the total profit reaches the target or risk thresholds are hit → all trades are closed. If that closure lines up with the final Friday session while Close all positions after the last session on Friday is enabled, the grid is flushed for the weekend and the panel flips to a Weekly flat status.
6. After a full closure, the Number of bars to wait after a full grid close before opening new positions timer may delay the restart: the EA waits for the configured number of bars before opening new positions, and the panel displays the remaining countdown.

### Next Step

Now proceed to the Money Management section to understand how Zyra allocates lots and controls capital usage.