BREAKING CHANGES:
- Phase locks now operate as safety floors only (no dynamic tightening)
- Adaptive trailing is phase-aware with ATR-based multipliers
- Partial closure schedule optimized (earlier triggers, larger percentages)
🎯 Solution 1: Decouple Phase Locks from Adaptive Trailing (PRIMARY)
- Modified ProfitMaximizer_PME.mqh: Phase locks = minimum profit guarantees only
* Removed progressive locking calculations (lines 1047-1101)
* Removed breathing room reduction logic
* Removed retreat tightening (multiplier now 1.0, was 1.2)
* Phase locks only move up when higher phases achieved, never tighten
- Modified PositionManager_PME_Complete.mqh: Phase-aware adaptive trailing
* CalculateTrailDistance(): Phase-based multipliers 2.5x-3.5x ATR (lines 980-1066)
* ApplyTrailingStop(): Respects phase floor minimums (lines 873-975)
* FIXED volatility logic: Now WIDENS stops in high vol by 30% (was tightening!)
*
17 KiB
ERMT PME v1.3 - COMPLETE IMPLEMENTATION SUMMARY
All Three Solutions Implemented
Release Date: 2025-12-03 Version: 1.3 COMPLETE Status: ✅ Ready for Testing
🎯 Implementation Overview
All three solutions from the analysis document have been successfully implemented:
✅ Solution 1: Decouple Phase Locks from Adaptive Trailing (PRIMARY)
✅ Solution 2: Optimize Partial Closures for Maximum Efficiency (SECONDARY)
✅ Solution 3: Implement Volatility-Aware Breathing Room (COMPLEMENTARY)
📋 Solution 1: Decoupled Phase Locks & Adaptive Trailing
Implementation Status: ✅ COMPLETE
Files Modified:
Modules_PME/ProfitMaximizer_PME.mqh(Lines 1020-1101)Modules_PME/PositionManager_PME_Complete.mqh(Lines 873-1066)ERMT_PME_1.3.mq5(Headers, parameters, initialization)
Key Changes:
Phase Locks → Safety Floors Only
// GetPhaseProtectionStop() - Line 1022
// v1.3: Calculate MINIMUM phase lock only (safety floor)
ENUM_PROFIT_PHASE highest_phase = m_trackers[index].highest_phase_achieved;
double minimum_lock = GetMinimumPhaseLock(highest_phase);
// NO progressive locking
// NO breathing room reduction
// NO dynamic tightening
// Just absolute minimum for highest phase achieved
Result: Phase locks never tighten on retracements, only move up when higher phases are achieved.
Adaptive Trailing → Phase-Aware
// CalculateTrailDistance() - Line 980
// v1.3: Phase-based trail multipliers
if(profit_points < 40) return 0; // No trail yet
else if(profit_points < 60) trail_multiplier = 2.5; // PROTECTION
else if(profit_points < 100) trail_multiplier = 2.2; // ACCUMULATION
else if(profit_points < 200) trail_multiplier = 1.8; // MAXIMIZATION
else if(profit_points < 400) trail_multiplier = 3.0; // RUNNER
else trail_multiplier = 3.5; // EXTREME
// CORRECTED volatility logic (widens in high vol, not tightens!)
if(vol_ratio > 1.5)
base_distance *= 1.3; // WIDEN trail by 30%
Result: Trail width automatically adjusts to profit phase, giving more room in higher profit zones.
Input Parameters:
// v1.3 optimized settings
InpTrailDistance = 50; // +25% wider (was 40)
InpTrailStep = 20; // +33% larger (was 15)
InpRetreatLockMultiplier = 1.0; // DISABLED (was 1.2)
InpFloorOnlyMode = true; // Floor-only phase locks
📋 Solution 2: Optimized Partial Closures
Implementation Status: ✅ COMPLETE
Files Modified:
Modules_PME/ProfitMaximizer_PME.mqh(Lines 392-504)ERMT_PME_1.3.mq5(Lines 142-153)
Key Enhancements:
Dynamic Partial Closure Optimization
// CalculateOptimalPartial() - Line 394
// v1.3: Multi-factor adjustment
// 1. Momentum-based
if(momentum_score > 2.0) modifier = 0.6; // Strong momentum: take less (let it run)
else if(momentum_score < 0.3) modifier = 1.5; // Weak momentum: take more aggressively
// 2. Volatility-based
if(volatility_context > 2.0) modifier = 1.3; // Extreme volatility: bank profit
else if(volatility < 0.5) modifier = 0.85; // Low volatility: can hold more
// 3. Retracement pressure
if(retracement > 40%) modifier = 1.4; // High retracement: bank what we have
else if(retracement > 25%) modifier = 1.2; // Moderate retracement: cautious
// 4. Time-in-phase
if(bars_in_phase > 50) modifier = 1.2; // Position stalling: bank more
// Apply all modifiers (capped at 50%-150% of base)
adjusted_percent = base_percent * momentum_modifier * volatility_modifier *
retracement_modifier * time_modifier;
Result: Partial closures adapt intelligently to market conditions, taking more profit in weak/volatile conditions, less in strong trends.
Optimized Partial Schedule:
// v1.3: Earlier triggers, larger percentages
InpPartialTrigger1 = 40; // was 50 | InpPartialPercent1 = 25; // was 20
InpPartialTrigger2 = 80; // was 100 | InpPartialPercent2 = 25; // was 20
InpPartialTrigger3 = 150; // was 200 | InpPartialPercent3 = 25; // was 25
InpPartialTrigger4 = 300; // was 400 | InpPartialPercent4 = 15; // was 20
InpRunnerPercentage = 10; // was 15 (smaller runner)
InpRunnerTrailMultiplier = 3.0; // was 2.0 (wider trail)
Progressive Banking:
- 40pts: 25% closed → 75% remaining
- 80pts: 25% closed → 50% remaining ✅ (+10% vs v1.2)
- 150pts: 25% closed → 25% remaining ✅ (+10% vs v1.2)
- 300pts: 15% closed → 10% runner
Result: 75% profit banked by 150 points (vs 65% by 200 points in v1.2) - 15% faster profit realization!
📋 Solution 3: Volatility-Aware Breathing Room
Implementation Status: ✅ COMPLETE
Files Modified:
Modules_PME/ProfitMaximizer_PME.mqh(Lines 957-1051)ERMT_PME_1.3.mq5(Lines 187-191)
Key Features:
ATR-Based Breathing Room Calculation
// CalculateDynamicBreathingRoom() - Line 959
// v1.3 SOLUTION 3: ATR-aware breathing room
// Calculate how many ATRs the peak profit represents
double profit_in_atr = peak_profit_price / atr;
// Scale breathing room by profit magnitude
if(profit_in_atr < 1.5) breathing_room_atr = 0.8; // Small profit: tight
else if(profit_in_atr < 3.0) breathing_room_atr = 1.5; // Moderate: standard
else if(profit_in_atr < 5.0) breathing_room_atr = 2.0; // Good: generous
else if(profit_in_atr < 8.0) breathing_room_atr = 2.5; // Large: very generous
else breathing_room_atr = 3.0; // Exceptional: maximum
// Phase-based multiplier (higher phases = more room)
switch(phase)
{
case PHASE_PROTECTION: phase_multiplier = 1.0; break; // Standard
case PHASE_ACCUMULATION: phase_multiplier = 1.2; break; // Generous
case PHASE_MAXIMIZATION: phase_multiplier = 1.4; break; // Very generous
case PHASE_RUNNER: phase_multiplier = 1.8; break; // Ultra generous
case PHASE_EXTREME: phase_multiplier = 2.0; break; // Maximum
}
// Volatility adjustment (WIDEN in high volatility!)
if(volatility_context > 1.5)
breathing_room_atr *= 1.3; // +30% more room
// Convert back to points
breathing_room_points = (breathing_room_atr * atr) / point_value;
Example Scenarios:
| Profit | ATR | Phase | Volatility | Breathing Room | Old (50% fixed) | Improvement |
|---|---|---|---|---|---|---|
| 100pts | 50pts | MAXIMIZATION | Normal | 2.0 ATR × 1.4 = 140pts | 50pts | +180% |
| 150pts | 30pts | RUNNER | High | 2.5 ATR × 1.8 × 1.3 = 175pts | 75pts | +133% |
| 80pts | 40pts | ACCUMULATION | Low | 1.5 ATR × 1.2 × 0.9 = 65pts | 40pts | +63% |
Result: Breathing room now scales intelligently with market conditions - wider in volatile markets, tighter in stable conditions.
Configuration Options:
// ERMT_PME_1.3.mq5 - Lines 189-191
input bool InpUseDynamicPartials = true; // Solution 2: Dynamic partial adjustment
input bool InpUseATRBreathingRoom = false; // Solution 3: ATR-aware (Advanced, OFF by default)
input bool InpFloorOnlyMode = true; // Solution 1: Floor-only (ON by default)
Note: Solution 3 is OFF by default because Solution 1 (floor-only mode) already provides excellent protection. Enable Solution 3 for even more sophisticated breathing room in highly volatile markets.
🎛️ Configuration Modes
Mode 1: Conservative (Recommended for Live)
InpFloorOnlyMode = true ✅ Phase locks as safety floors only
InpUseDynamicPartials = true ✅ Smart partial adjustments
InpUseATRBreathingRoom = false ❌ Use floor-only mode (simpler)
Best for: Most traders, stable to moderate volatility
Mode 2: Aggressive (Maximum Freedom)
InpFloorOnlyMode = true ✅ Phase locks as safety floors
InpUseDynamicPartials = true ✅ Smart partial adjustments
InpUseATRBreathingRoom = true ✅ ATR-aware breathing room (advanced)
Best for: Experienced traders, highly volatile markets (crypto, news events)
Mode 3: Classic v1.2 Style (Comparison Testing)
InpFloorOnlyMode = false ❌ Use old progressive locking
InpUseDynamicPartials = false ❌ Fixed partial percentages
InpUseATRBreathingRoom = false ❌ Fixed breathing room
Best for: A/B testing v1.3 vs v1.2 performance
📊 Expected Performance Improvements
Combined Impact of All Three Solutions:
| Metric | v1.2 Baseline | v1.3 Target | Improvement | Primary Solution |
|---|---|---|---|---|
| Premature Exits | 60-70% | <20% | -71% | Solution 1 |
| Avg Profit/Trade | 85pts | 130pts | +53% | Solutions 1+2 |
| Runner Success | 15% | 40% | +167% | Solutions 1+3 |
| Profit @ 150pts | 65% | 75% | +15% | Solution 2 |
| High Vol Survival | 40% | 70% | +75% | Solution 3 |
| Stop Hits (Natural) | 45% | <15% | -67% | Solutions 1+3 |
Synergy Effects:
- Solutions 1+2: Positions stay open longer → more partials trigger → higher total profit
- Solutions 1+3: Phase floors + ATR breathing → survive extreme volatility → capture recovery moves
- Solutions 2+3: Dynamic partials + breathing room → optimal profit taking in any market condition
🧪 Testing Methodology
Phase 1: Individual Solution Testing (1 week each)
Test 1: Solution 1 Only
InpFloorOnlyMode = true
InpUseDynamicPartials = false
InpUseATRBreathingRoom = false
Measure: Premature exit rate, average profit, runner survival
Test 2: Solutions 1+2
InpFloorOnlyMode = true
InpUseDynamicPartials = true
InpUseATRBreathingRoom = false
Measure: Partial closure efficiency, profit banking speed
Test 3: Solutions 1+2+3 (Full v1.3)
InpFloorOnlyMode = true
InpUseDynamicPartials = true
InpUseATRBreathingRoom = true
Measure: High volatility performance, maximum breathing room effectiveness
Phase 2: A/B Comparison (2 weeks)
| Account | Configuration | Purpose |
|---|---|---|
| Demo 1 | v1.2 (baseline) | Control group |
| Demo 2 | v1.3 Mode 1 (conservative) | Standard comparison |
| Demo 3 | v1.3 Mode 2 (aggressive) | Advanced comparison |
Track: Win rate, average profit, maximum adverse excursion (MAE), maximum favorable excursion (MFE), Sharpe ratio
Phase 3: Live Validation (4 weeks)
- Week 1: 50% position size, Mode 1 (conservative)
- Week 2: 75% position size, continue Mode 1
- Week 3: 100% position size if metrics meet targets
- Week 4: Optional Mode 2 (aggressive) testing with 50% size
Success Criteria (must meet 4 of 6):
- ✅ Premature exit rate < 25%
- ✅ Average profit > 110 points
- ✅ Runner survival > 30%
- ✅ Profit @ 150pts > 70%
- ✅ Sharpe ratio improvement > 0.25
- ✅ Maximum drawdown < 15%
📝 Log Messages to Monitor
Solution 1: Phase Locks
✅ "Position #12345: Phase floor set at 1.2050 (50.0 pts minimum from MAXIMIZATION phase)"
✅ "Position #12345: Adaptive trailing activated at 85.0 points profit"
✅ "Position #12345: Trail distance calculated: 75.0 points (phase-based: 2.2x ATR)"
✅ "Position #12345: High volatility (1.65) - widening trail by 30%"
Solution 2: Dynamic Partials
✅ "Position #12345: Strong momentum (2.15) - reducing partial by 40%"
✅ "Position #12345: Weak momentum (0.25) - increasing partial by 50%"
✅ "Position #12345: Extreme volatility (2.30) - increasing partial by 30%"
✅ "Position #12345: High retracement (45.0%) - increasing partial by 40%"
✅ "Position #12345: Partial close adjustment - Base: 25.0%, Final: 37.5%"
Solution 3: ATR Breathing Room
✅ "Position #12345: Dynamic breathing room - 2.50 ATR = 125.0 points (Profit: 4.2 ATR, Phase: MAXIMIZATION, Vol: 1.75)"
✅ "Position #12345: High volatility - expanding breathing room to 3.25 ATR"
🐛 Troubleshooting
Issue 1: Partials Not Adjusting Dynamically
Symptom: Partials always same % regardless of conditions Check:
InpUseDynamicPartials = true✅InpPartialEnabled = true✅- Look for "Partial close adjustment" messages in logs
Fix: Ensure both flags are enabled in EA inputs
Issue 2: ATR Breathing Room Not Applied
Symptom: No "Dynamic breathing room" messages Check:
InpUseATRBreathingRoom = true✅InpFloorOnlyMode = true✅ (required for v1.3 logic)- ATR indicator loading properly (check TechnicalAnalysis_PME_Merged.mqh)
Fix: Enable both flags, verify ATR calculation
Issue 3: Phase Floors Not Holding
Symptom: Positions closing below phase minimum guarantees Check:
InpUsePhaseProfitLocks = true✅InpFloorOnlyMode = true✅- Phase minimum values not set to 0
Fix: Verify phase lock inputs (10/25/50/100/200)
Issue 4: Trail Too Tight in High Volatility
Symptom: Stops hitting during volatility spikes despite fixes Check:
InpAdaptiveTrailing = true✅InpHighVolatilityMultiplier = 1.3✅ (should WIDEN, not 0.7)- Log shows "widening trail by 30%" not "tightening"
Fix: Ensure volatility multiplier > 1.0 (1.3-1.5 recommended)
📈 Performance Benchmarks
Track These KPIs Weekly:
Primary Metrics (Solution 1):
- Premature exit rate < 25%
- Average profit per trade > 110 points
- Runner survival rate > 30%
Secondary Metrics (Solution 2):
- 75%+ profit banked by 150 points
- Dynamic partial adjustments logged 50%+ of trades
- Partial close timing optimized vs fixed schedule
Tertiary Metrics (Solution 3):
- High volatility survival rate > 65%
- Breathing room messages during volatile periods
- ATR-based adjustments correlate with volatility events
Overall System Health:
- Sharpe ratio improvement > 0.3
- Maximum drawdown < 15%
- Win rate maintained or improved
- Risk-adjusted return (Sortino) > 1.5
🔄 Rollback Plan
If v1.3 underperforms:
Rollback to v1.2:
cd "/path/to/ERMT_PMEx"
cp ERMT_PME_1.2_BACKUP.mq5 ERMT_PME_1.2.mq5
cp Modules_PME/ProfitMaximizer_PME_BACKUP.mqh Modules_PME/ProfitMaximizer_PME.mqh
cp Modules_PME/PositionManager_PME_Complete_BACKUP.mqh Modules_PME/PositionManager_PME_Complete.mqh
Gradual Rollback (if only one solution problematic):
- Disable Solution 3:
InpUseATRBreathingRoom = false - Disable Solution 2:
InpUseDynamicPartials = false - Disable Solution 1:
InpFloorOnlyMode = false(back to v1.2 behavior)
✅ Implementation Checklist
Pre-Deployment:
- Solution 1 implemented and tested locally
- Solution 2 implemented and tested locally
- Solution 3 implemented and tested locally
- All three solutions tested together on demo
- Compilation successful (0 errors, 0 warnings)
- Log messages verified for all three solutions
- Backup of v1.2 files created
- Input parameters documented
Demo Testing (Minimum 20 trades):
- Solution 1: Positions surviving retracements
- Solution 2: Dynamic partial adjustments working
- Solution 3: ATR breathing room expanding/contracting
- No premature exits below phase floors
- Runners reaching 300+ points
- Partials triggering at 40/80/150/300
Live Deployment:
- Demo results meet success criteria (4 of 6 metrics)
- 50% position size for first week
- Daily monitoring of log messages
- Weekly performance review
- Gradual increase to 100% after validation
📞 Documentation & Support
- Analysis Document:
ANALYSIS_AdaptiveTrailing_PhaseLock.md - Changelog:
V1.3_CHANGELOG.md - Quick Start:
V1.3_QUICK_START.md - This Document:
V1.3_COMPLETE_IMPLEMENTATION.md
🎓 Key Concepts Summary
The v1.3 Philosophy:
"Phase locks guarantee minimums, adaptive trailing captures maximums, intelligent partials realize profits optimally, and ATR breathing room adapts to market conditions - all working in harmony, not conflict."
Three-Layer Protection:
- Layer 1 (Foundation): Phase lock floors - "You will never lose more than X"
- Layer 2 (Dynamic): Adaptive trailing - "Follow the move intelligently"
- Layer 3 (Optimization): Smart partials + breathing room - "Take profit optimally, give room to breathe"
Design Principles:
- Separation of Concerns: Each system has one job, does it well
- Passive Safety: Phase locks don't interfere with active management
- Active Optimization: Trailing and partials respond to market conditions
- Intelligent Adaptation: ATR breathing room scales with volatility
🚀 Next Steps
- Compile v1.3: Open MetaEditor, compile
ERMT_PME_1.3.mq5 - Attach to Demo Chart: Use Mode 1 (conservative) configuration
- Monitor First 10 Trades: Watch for all three solution behaviors
- Review Logs Daily: Verify dynamic adjustments happening
- Compare to v1.2: Run side-by-side for 2 weeks
- Deploy to Live: Only after demo validation (50% size first week)
Implementation Date: 2025-12-03 Version: 1.3 COMPLETE Status: ✅ ALL THREE SOLUTIONS IMPLEMENTED - READY FOR TESTING
Expected Live Deployment: After successful demo testing (minimum 20 trades, 2 weeks)