# Advanced Features

## Trade Protection & Profit Management

BananaEA includes sophisticated trade management features that protect profits and reduce risk as trades move in your favor.

***

## Break-Even Protection

### What It Does

**Automatically moves stop loss to entry price** when trade reaches profit threshold, eliminating risk of loss.

⚠️ **CRITICAL SETTING:** Break-even is a **toggle-based feature** in v4.x.x. Proper configuration is essential for trade protection.

### Settings

**`BreakEvenMethod`** - Toggle Control

**What it does:** Selects break-even calculation method (or disables feature entirely).

**Configuration:**

* **Default:** BE\_ATR (ATR-based calculation)
* **Options:**
  * **BE\_Disabled (0)** — ❌ Feature OFF (SL stays at original distance)
  * **BE\_Fixed (1)** — Fixed pips
  * **BE\_CandleRange (2)** — Risk:Reward ratio
  * **BE\_ATR (3)** — ATR multiplier (recommended)

**Why toggle-based is critical:**

* ✅ **Explicit control:** You choose EXACTLY how break-even works
* ✅ **Disable when needed:** Set to "Disabled" for strategies that don't need BE
* ✅ **Flexibility:** Switch between Fixed pips, ATR, or R:R without code changes
* ⚠️ **No ambiguity:** "Disabled" means feature is OFF (not just set to 0 value)

**`BE_Value`** - Trigger Value

**What it does:** Break-even trigger value (meaning depends on BreakEvenMethod).

**Configuration:**

* **Default:** 2.0
* **Context-aware:**
  * **BE\_Fixed:** Value in **pips** (e.g., 20 = move BE after 20 pips profit)
  * **BE\_ATR:** **Multiplier** (e.g., 2.0 = move BE after 2 × ATR profit)
  * **BE\_CandleRange:** **R:R ratio** (e.g., 1.0 = move BE after 1R profit)
  * **BE\_Disabled:** Value ignored (feature is OFF)

**Examples:**

```
Aggressive (scalping):
BreakEvenMethod = BE_Fixed
BE_Value = 10 pips
→ Move to BE after 10 pips profit

Balanced (swing trading) - RECOMMENDED:
BreakEvenMethod = BE_ATR
BE_Value = 2.0
→ Move to BE after 2 × ATR profit

Conservative (position trading):
BreakEvenMethod = BE_ATR
BE_Value = 3.0
→ Move to BE after 3 × ATR profit

Disabled (no BE protection):
BreakEvenMethod = BE_Disabled
BE_Value = (ignored)
→ Feature is OFF, SL never moves to entry
```

### How It Works

**Example calculation:**

```
Entry: 1.1000
SL: 1.0980 (20 pips)
TP: 1.1100 (100 pips)
BreakEvenTrigger = 1.0 ATR (= 10 pips)
BreakEvenOffset = 2 pips

Trade reaches 1.1010 (10 pips profit = 1.0 ATR)
→ SL moves to 1.1002 (entry + 2 pip offset)
→ Guaranteed 2 pip profit if reversed
```

### Best Practices

**Aggressive break-even (scalping):**

```
BreakEvenMethod = BE_Fixed
BE_Value = 10 pips
```

* Moves to BE quickly
* Protects capital early
* Higher chance of BE stop-outs

**Balanced break-even (swing trading) - RECOMMENDED:**

```
BreakEvenMethod = BE_ATR
BE_Value = 2.0
```

* Gives trade room to breathe
* Adapts to market volatility
* Recommended for most traders

**Conservative break-even (position trading):**

```
BreakEvenMethod = BE_ATR
BE_Value = 3.0
```

* Only activates when trade well in profit
* Minimizes BE stop-outs
* Maximizes trend capture

**Disabled (no BE protection):**

```
BreakEvenMethod = BE_Disabled
```

* Feature completely OFF
* SL stays at original distance
* Use for strategies that need fixed SL

***

## Partial Close

### What It Does

**Takes partial profit at target while leaving remaining position to run** toward final TP.

⚠️ **CRITICAL SETTING:** Partial close is a **toggle-based feature** in v4.x.x. Proper configuration impacts profit capture strategy.

### Settings

**`PartialCloseMethod`** - Toggle Control

**What it does:** Selects partial close calculation method (or disables feature entirely).

**Configuration:**

* **Default:** PC\_ATR (ATR-based calculation)
* **Options:**
  * **PC\_Disabled (0)** — ❌ Feature OFF (trade runs to full TP or SL)
  * **PC\_Fixed (1)** — Fixed pips
  * **PC\_CandleRange (2)** — Risk:Reward ratio
  * **PC\_ATR (3)** — ATR multiplier (recommended)

**Why toggle-based is critical:**

* ✅ **Profit strategy control:** You decide HOW to take partial profits
* ✅ **Disable when needed:** Set to "Disabled" for let-winners-run strategies
* ✅ **Method flexibility:** Choose Fixed pips, ATR, or R:R based on market conditions
* ⚠️ **Impact on returns:** Partial close reduces max profit but improves consistency

**`PC_Value`** - Trigger Value

**What it does:** Partial close trigger value (meaning depends on PartialCloseMethod).

**Configuration:**

* **Default:** 1.0
* **Context-aware:**
  * **PC\_Fixed:** Value in **pips** (e.g., 30 = close partial after 30 pips profit)
  * **PC\_ATR:** **Multiplier** (e.g., 1.0 = close partial after 1 × ATR profit)
  * **PC\_CandleRange:** **R:R ratio** (e.g., 2.0 = close partial after 2R profit)
  * **PC\_Disabled:** Value ignored (feature is OFF)

**`PartialClosePercentage`** - Amount to Close

**What it does:** Percentage of position to close (as decimal).

**Configuration:**

* **Default:** 0.5 (50%)
* **Range:** 0.25–0.75 (25%–75%)
* **Examples:**
  * 0.25 = Take small profit (25%), let majority run
  * 0.5 = Balanced (50% secure, 50% run) - recommended
  * 0.75 = Take most profit (75%), minimal runner

### How It Works

**Example:**

```
Entry: 1 lot BUY at 1.1000
SL: 1.0980 (20 pips)
TP: 1.1100 (100 pips)
PartialCloseTrigger = 2.0 ATR (= 20 pips)
PartialClosePercent = 50%

Trade reaches 1.1020 (20 pips profit = 2.0 ATR)
→ Close 0.5 lot at 1.1020 (secure 10 pip profit × 0.5 lot)
→ Remaining 0.5 lot stays open targeting 1.1100
→ SL can be moved to BE on remaining position
```

### Strategy Benefits

**Why use partial close:**

* ✅ Secures profits early (removes anxiety)
* ✅ Lets winners run (captures big moves)
* ✅ Reduces impact of reversals
* ✅ Improves psychological confidence

**Profit comparison:**

**Without partial close:**

* Win: +100 pips × 1 lot = +100 pips
* Loss (reversed from +50 pips): -20 pips × 1 lot = -20 pips

**With partial close (50% at 2.0 ATR):**

* Win: (+20 pips × 0.5 lot) + (+100 pips × 0.5 lot) = +60 pips
* Loss (reversed from +50 pips): (+20 pips × 0.5 lot) + (-20 pips × 0.5 lot) = 0 pips

**Result:** Partial close protected you from loss in reversal scenario.

***

## Trailing Stop

### What It Does

**Follows price in profit, locking in gains while allowing trade to capture larger moves.**

⚠️ **CRITICAL SETTING:** Trailing stop is a **toggle-based feature** in v4.x.x with **6 calculation methods**. Proper configuration maximizes profit capture.

### Settings

**`TrailingMethod`** - Toggle Control

**What it does:** Selects trailing stop calculation method (or disables feature entirely).

**Configuration:**

* **Default:** Trail\_ATR (ATR-based calculation)
* **Options:**
  * **Trail\_Disabled (0)** — ❌ Feature OFF (SL stays fixed)
  * **Trail\_Fixed (1)** — Fixed pips
  * **Trail\_ATR (2)** — ATR multiplier (recommended)
  * **Trail\_Candle (3)** — Candle-based (bars)
  * **Trail\_RMultiple (4)** — Risk:Reward ratio
  * **Trail\_MA (5)** — Moving average-based

**Why toggle-based is critical:**

* ✅ **Most flexible feature:** 6 different trailing methods for different strategies
* ✅ **Disable when needed:** Set to "Disabled" for fixed SL strategies
* ✅ **Method variety:** From simple Fixed pips to advanced MA-based trailing
* ⚠️ **Exit timing impact:** Trailing method dramatically affects when trades close

**`Trail_ActivationValue`** - Activation Trigger

**What it does:** Minimum profit before trailing starts (meaning depends on TrailingMethod).

**Configuration:**

* **Default:** 5.0
* **Context-aware:**
  * **Trail\_Fixed:** Value in **pips** (e.g., 20 = start trailing after 20 pips profit)
  * **Trail\_ATR:** **Multiplier** (e.g., 5.0 = start after 5 × ATR profit)
  * **Trail\_Candle:** **Bars** (e.g., 3 = start after 3 bars in profit)
  * **Trail\_RMultiple:** **R:R ratio** (e.g., 2.0 = start after 2R profit)
  * **Trail\_MA:** **Rs to start** (0 = immediate)
  * **Trail\_Disabled:** Value ignored (feature is OFF)

**`Trail_DistanceValue`** - Trailing Distance

**What it does:** Distance to trail behind price (meaning depends on TrailingMethod).

**Configuration:**

* **Default:** 2.0
* **Context-aware:**
  * **Trail\_Fixed:** Value in **pips** (e.g., 15 = trail 15 pips behind price)
  * **Trail\_ATR:** **Multiplier** (e.g., 2.0 = trail 2 × ATR behind price)
  * **Trail\_Candle:** **Bars** (e.g., 2 = trail behind 2-bar high/low)
  * **Trail\_RMultiple:** **R:R ratio** (e.g., 1.0 = trail at 1R distance)
  * **Trail\_MA:** **EMA period** (e.g., 20 = use 20 EMA as trailing stop)
  * **Trail\_Disabled:** Value ignored (feature is OFF)

**`TrailMinimumMovement`** - Update Threshold

**What it does:** Minimum price movement in pips required to update trailing SL.

**Configuration:**

* **Default:** 1.0 pips
* **Range:** 0.5–20 pips
* **Purpose:** Reduces broker API calls by 70-90% (avoid micro-trailing, saves costs)

### How It Works

**Example:**

```
Entry: 1.1000 BUY
SL: 1.0980 (20 pips)
TrailingTrigger = 1.5 ATR (= 15 pips)
TrailingDistance = 1.0 ATR (= 10 pips)

Price reaches 1.1015 (15 pips profit = 1.5 ATR)
→ Trailing activates
→ SL moves to 1.1005 (current price 1.1015 - 10 pips trailing distance)

Price continues to 1.1040
→ SL trails to 1.1030 (1.1040 - 10 pips)
→ Locked in 30 pips profit

Price reverses to 1.1030
→ SL triggered at 1.1030
→ Trade closes with 30 pip profit (instead of riding it back down)
```

### Trailing Strategies

**Tight trailing (scalping):**

```
TrailingMethod = Trail_Fixed
Trail_ActivationValue = 10 pips
Trail_DistanceValue = 8 pips
TrailMinimumMovement = 2 pips
```

* Follows price closely
* Captures small moves
* Higher chance of early exits

**Balanced trailing (swing trading) - RECOMMENDED:**

```
TrailingMethod = Trail_ATR
Trail_ActivationValue = 5.0 (5 × ATR)
Trail_DistanceValue = 2.0 (2 × ATR)
TrailMinimumMovement = 1.0 pips
```

* Adapts to market volatility
* Balances capture vs exits
* Recommended for most traders

**Wide trailing (trend trading):**

```
TrailingMethod = Trail_ATR
Trail_ActivationValue = 8.0 (8 × ATR)
Trail_DistanceValue = 3.0 (3 × ATR)
TrailMinimumMovement = 2.0 pips
```

* Maximizes trend capture
* Minimizes premature exits
* Best for strong trending markets

**Advanced: MA-based trailing:**

```
TrailingMethod = Trail_MA
Trail_ActivationValue = 0 (immediate)
Trail_DistanceValue = 20 (20 EMA)
TrailMinimumMovement = 1.0 pips
```

* Uses moving average as dynamic SL
* Follows trend structure
* Advanced strategy for experienced traders

**Disabled (no trailing):**

```
TrailingMethod = Trail_Disabled
```

* Feature completely OFF
* SL stays at original distance (or BE if activated)
* Use for fixed TP strategies

***

## Combining Features

### Example 1: Maximum Protection Strategy

**Goal:** Secure profits at every stage, minimize risk.

```
BreakEvenMethod = BE_ATR
BE_Value = 2.0 (2 × ATR)

PartialCloseMethod = PC_ATR
PC_Value = 3.0 (3 × ATR)
PartialClosePercentage = 0.5 (50%)

TrailingMethod = Trail_ATR
Trail_ActivationValue = 5.0 (5 × ATR)
Trail_DistanceValue = 2.0 (2 × ATR)
TrailMinimumMovement = 1.0 pips
```

**Workflow:**

1. Trade reaches 1.0 ATR profit → Move to break-even (no risk)
2. Trade reaches 2.0 ATR profit → Close 50% (secure profit)
3. Trade reaches 3.0 ATR profit → Start trailing remaining 50%
4. Remaining position trails to capture extended moves

### Example 2: Let Winners Run Strategy

**Goal:** Capture maximum profit on winning trades.

```
BreakEvenMethod = BE_ATR
BE_Value = 3.0 (3 × ATR)

PartialCloseMethod = PC_Disabled

TrailingMethod = Trail_ATR
Trail_ActivationValue = 3.0 (3 × ATR)
Trail_DistanceValue = 3.0 (3 × ATR)
TrailMinimumMovement = 2.0 pips
```

**Workflow:**

1. Trade reaches 2.0 ATR profit → Move to break-even + start trailing
2. No partial close (full position stays)
3. Wide trailing distance (2.0 ATR) gives trade maximum room
4. Captures full profit of trending moves

### Example 3: Scalping Strategy

**Goal:** Quick in, quick out with secured profits.

```
BreakEvenMethod = BE_Fixed
BE_Value = 10 pips

PartialCloseMethod = PC_Fixed
PC_Value = 20 pips
PartialClosePercentage = 0.75 (75%)

TrailingMethod = Trail_Disabled
```

**Workflow:**

1. Trade reaches 0.5 ATR → Move to break-even quickly
2. Trade reaches 1.0 ATR → Close 75% (secure most profit)
3. Remaining 25% runs to full TP
4. No trailing (rely on fixed TP for remaining position)

***

## Best Practices

### Feature Activation Order

**Logical progression:**

1. **Break-even** (earliest) → Eliminates risk
2. **Partial close** (middle) → Secures initial profit
3. **Trailing** (latest) → Maximizes extended profit

**Recommended timing:**

```
BE_Value < PC_Value < Trail_ActivationValue

Example (ATR-based):
BreakEvenMethod = BE_ATR, BE_Value = 2.0
PartialCloseMethod = PC_ATR, PC_Value = 3.0
TrailingMethod = Trail_ATR, Trail_ActivationValue = 5.0

Result:
Break-even at 2 × ATR
Partial close at 3 × ATR
Trailing starts at 5 × ATR
```

### ATR vs Fixed Pips

**For advanced features, ATR-based is recommended:**

* Adapts to market volatility
* Works across different trading sessions
* Consistent behavior across symbols

**Fixed pips can be used for:**

* Specific strategies with consistent volatility
* Backtested exact values
* Simple, predictable behavior

### Performance Optimization

**Test these combinations in backtesting:**

1. Break-even only
2. Break-even + partial close
3. Break-even + trailing
4. All three features combined

**Analyze:**

* Win rate impact
* Average profit per trade
* Maximum drawdown
* Profit factor

***

## Troubleshooting

### Issue: Break-Even Triggered Too Early

**Symptoms:** Many trades hit BE then reverse for full TP.

**Solutions:**

* Increase `BreakEvenTrigger` (try 1.5 or 2.0 ATR)
* Review entry quality (early BE may indicate weak entries)
* Consider skipping BE for trend-following strategies

### Issue: Partial Close Reduces Profit

**Symptoms:** Winners would have hit full TP with full position.

**Solutions:**

* Reduce `PartialClosePercent` (try 25% instead of 50%)
* Increase `PartialCloseTrigger` (close later, closer to TP)
* Test disabling partial close for trending markets

### Issue: Trailing Stops Out Too Early

**Symptoms:** Trade trails then stops out before reaching TP.

**Solutions:**

* Increase `TrailingDistance` (give trade more room)
* Increase `TrailingTrigger` (start trailing later)
* Increase `TrailMinimumMovement` (reduce micro-adjustments)
* Consider using break-even + fixed TP instead

***

## Professional Robustness Metrics

### What It Does

**BananaEA v4.4.6 includes composite fitness scoring** that combines multiple professional metrics to evaluate EA performance beyond simple profit.

### Composite Fitness Score

**What it measures:** Overall EA quality using industry-standard robustness metrics.

**Components:**

1. **Sharpe Ratio** — Risk-adjusted returns (return per unit of volatility)
2. **Calmar Ratio** — Return vs maximum drawdown (higher = better risk management)
3. **Recovery Factor** — Net profit divided by maximum drawdown (profit efficiency)

**Why it matters:**

* **Optimization:** MT4 Strategy Tester can optimize for composite fitness, not just profit
* **Real-world viability:** High composite fitness = sustainable, robust trading strategy
* **Risk awareness:** Balances profit with drawdown control and consistency

### Configuration

**Optimization setup:**

```
In Strategy Tester → Optimization Settings:
Custom Optimization Criterion = "Composite Fitness"
```

**How to enable:**

1. Open MT4 Strategy Tester
2. Select BananaEA Expert Advisor
3. Click "Expert Properties"
4. Check "Optimization" tab
5. Select "Custom" optimization criterion
6. EA will use composite fitness automatically

### Metric Breakdown

**Sharpe Ratio:**

* **Formula:** (Average Return - Risk-Free Rate) / Standard Deviation of Returns
* **Interpretation:**
  * < 1.0 = Poor risk-adjusted returns
  * 1.0-2.0 = Good (acceptable)
  * 2.0-3.0 = Very good
  * > 3.0 = Excellent
* **Purpose:** Measures consistency of returns relative to volatility

**Calmar Ratio:**

* **Formula:** Annual Return / Maximum Drawdown
* **Interpretation:**
  * < 1.0 = Drawdown exceeds annual return (poor)
  * 1.0-2.0 = Acceptable
  * 2.0-5.0 = Good
  * > 5.0 = Excellent
* **Purpose:** Evaluates profit generation vs worst drawdown

**Recovery Factor:**

* **Formula:** Net Profit / Maximum Drawdown
* **Interpretation:**
  * < 2.0 = Poor (small profit relative to DD)
  * 2.0-5.0 = Acceptable
  * 5.0-10.0 = Good
  * > 10.0 = Excellent
* **Purpose:** Measures how efficiently EA recovers from drawdowns

### Example Comparison

**Strategy A: High Profit, High Risk**

```
Net Profit: $50,000
Max Drawdown: $25,000
Sharpe: 0.8
Calmar: 1.2
Recovery: 2.0
Composite Fitness: LOW (risky despite profit)
```

**Strategy B: Moderate Profit, Low Risk**

```
Net Profit: $30,000
Max Drawdown: $5,000
Sharpe: 2.5
Calmar: 6.0
Recovery: 6.0
Composite Fitness: HIGH (sustainable, robust)
```

**Result:** Strategy B is superior for long-term trading despite lower absolute profit.

### Best Practices

**Optimization workflow:**

1. Run optimization with composite fitness criterion
2. Review top 10 results
3. Prioritize sets with:
   * Sharpe > 1.5
   * Calmar > 2.0
   * Recovery > 3.0
4. Forward test top candidates on demo account

**Live deployment:**

* Choose optimization sets with highest composite fitness
* Avoid sets with excellent profit but poor metrics (risky)
* Monitor live metrics alongside profit

**💡 See also:** [Professional Metrics Guide](https://itradeaims.gitbook.io/banana-ea/backtesting-and-optimization/backtesting-optimization/professional-metrics) for in-depth metric analysis.

***

## Optimization Set Identification

### What It Does

**Labels your current EA configuration** for easy tracking and comparison of different optimization sets.

### Settings

**`OptimizationSetName`**

**What it does:** Displays a custom name on the dashboard to identify which optimization set is currently active.

**Configuration:**

* **Default:** "" (empty string)
* **Format:** Text string (alphanumeric + underscores recommended)
* **Visibility:** Shows in dashboard panel for instant identification
* **Purpose:** Track which optimization pass/strategy is deployed

### Use Cases

**Multiple optimization sets:**

```
Set A: "DAX_M5_Conservative_v1.2"
Set B: "DAX_M5_Aggressive_v1.2"
Set C: "EURUSD_H1_Balanced_v2.0"

Dashboard shows: "Active Set: DAX_M5_Conservative_v1.2"
```

**Version tracking:**

```
"Champion_Pass6859_Dec2025"
"Conservative_Pass4950_Nov2025"
"HighFreq_Pass7234_Jan2026"

Easily identify which optimization pass is deployed
```

**Strategy variants:**

```
"Prop_Firm_Conservative"
"Personal_Aggressive"
"Low_DD_Safe_Mode"
```

### Naming Best Practices

**Include:**

* **Symbol:** DAX, EURUSD, GBPUSD
* **Timeframe:** M5, H1, H4
* **Strategy type:** Conservative, Aggressive, Balanced
* **Version/Date:** v1.0, Dec2025, Pass6859

**Format examples:**

```
[Symbol]_[Timeframe]_[Strategy]_[Version]

DAX_M5_Conservative_v1.2
EURUSD_H1_Balanced_Dec2025
GBPUSD_M15_Aggressive_Pass7234
```

**Recommendations:**

* Use underscores (not spaces)
* Keep under 30 characters
* Be descriptive but concise
* Update when switching optimization sets

**💡 See also:** [General Settings](https://itradeaims.gitbook.io/banana-ea/complete-user-guide/general-settings#optimizationsetname---optimization-set-identifier) for detailed parameter documentation.

***

## Related Settings

* [**Stop Loss & Take Profit**](https://github.com/itradeaims/bananaEA-dev/blob/dev/gitbook/complete-user-guide/settings-guide/stop-loss-take-profit.md) - SL/TP calculation methods
* [**Trade Management Mode**](https://itradeaims.gitbook.io/banana-ea/complete-user-guide/settings-guide/trade-management-mode) - Magic = 0 enhancements
* [**Risk Management**](https://itradeaims.gitbook.io/banana-ea/complete-user-guide/settings-guide/risk-management) - Position sizing with advanced features
* [**General Settings**](https://itradeaims.gitbook.io/banana-ea/complete-user-guide/settings-guide/general-settings) - OptimizationSetName parameter details

***

## Quick Reference

| Feature       | Recommended Trigger | Purpose                |
| ------------- | ------------------- | ---------------------- |
| Break-Even    | 1.0 ATR             | Eliminate risk         |
| Partial Close | 2.0 ATR             | Secure initial profit  |
| Trailing Stop | 1.5-3.0 ATR         | Capture extended moves |

**Balanced configuration (recommended):**

```
BreakEvenMethod = BE_ATR
BE_Value = 2.0 (2 × ATR)

PartialCloseMethod = PC_ATR
PC_Value = 3.0 (3 × ATR)
PartialClosePercentage = 0.5 (50%)

TrailingMethod = Trail_ATR
Trail_ActivationValue = 5.0 (5 × ATR)
Trail_DistanceValue = 2.0 (2 × ATR)
TrailMinimumMovement = 1.0 pips
```

**Professional metrics targets:**

```
Sharpe Ratio: > 1.5 (good), > 2.0 (excellent)
Calmar Ratio: > 2.0 (acceptable), > 5.0 (excellent)
Recovery Factor: > 3.0 (acceptable), > 6.0 (excellent)
Composite Fitness: Optimize for highest combined score
```
