diff --git a/OPTIMIZATION_INTEGRATION_GUIDE.md b/OPTIMIZATION_INTEGRATION_GUIDE.md index 7df306d..5ea7ae0 100644 --- a/OPTIMIZATION_INTEGRATION_GUIDE.md +++ b/OPTIMIZATION_INTEGRATION_GUIDE.md @@ -8,7 +8,7 @@ ## 🎯 Was wurde implementiert? -### 1. **Dynamic Confidence Threshold Optimizer** 🎚️ +### 1. **Dynamic Confidence Threshold Optimizer** 🎚️ (B) **Was es tut:** - Analysiert deine letzten 20 Trades @@ -25,7 +25,7 @@ - ✅ Schützt bei schlechter Performance - ✅ Session-spezifisch (Asian vs NY) -### 2. **Enhanced Signal Scoring** 🔍 +### 2. **Enhanced Signal Scoring** 🔍 (C) **Was es tut:** - Erweitert dein bestehendes Trend-System um 4 neue Faktoren: @@ -43,6 +43,23 @@ - ✅ Filtert schwache Setups raus - ✅ Nutzt dein bestehendes System als Basis +### 3. **Enhanced Trailing Stop** 📈 (D) + +**Was es tut:** +- Verbesserte Trailing Stop Logik mit 5 Features: + 1. **Early Breakeven** - Bei 30% (statt 50%) + 5 Pips Buffer + 2. **Multi-Tier Profit Locking** - 3 Stufen (50%/75%/90%) + 3. **ATR-Based Trailing** - Dynamisch statt fix (1.0 × ATR) + 4. **Time-Based Breakeven** - Auto-BE nach 4 Stunden + 5. **Session-Aware** - Größere Trails bei NY (1.5 × ATR) + +**Vorteile:** +- ✅ Früher Schutz (30% statt 50%) +- ✅ Mehr Profit gesichert (Multi-tier) +- ✅ Passt sich Volatilität an (ATR) +- ✅ Zeit-basierte Absicherung +- ✅ Optimiert pro Session + --- ## 📦 Installation @@ -190,9 +207,82 @@ execute_trade_v2_adaptive( --- -### Option C: Beide kombiniert (EMPFOHLEN!) +### Option D: Enhanced Trailing Stop Only -**Cell 1: Setup beide Module** +**Füge eine neue Cell hinzu:** + +```python +# ========================================== +# ENHANCED TRAILING STOP SETUP +# ========================================== + +from enhanced_trailing_stop import EnhancedTrailingStopManager, create_enhanced_position_monitor + +# Initialize Manager +enhanced_trailing = EnhancedTrailingStopManager( + # Early Breakeven + breakeven_trigger_pct=0.30, # Bei 30% zu TP (früher!) + breakeven_buffer_pips=5, # +5 Pips über BE + + # Multi-tier Profit Locking + tier1_trigger=0.50, # Bei 50% → Lock 25% + tier1_lock_pct=0.25, + tier2_trigger=0.75, # Bei 75% → Lock 50% + tier2_lock_pct=0.50, + tier3_trigger=0.90, # Bei 90% → Lock 75% + tier3_lock_pct=0.75, + + # ATR-based Trailing + use_atr_trailing=True, + atr_multiplier=1.0, # Trail by 1.0 × ATR + + # Time-based Breakeven + time_based_breakeven=True, + hours_to_breakeven=4.0, # Auto-BE nach 4h + + # Session-aware Multipliers + session_trailing_multipliers={ + 'asian': 1.0, # Standard + 'ny': 1.5, # Größer (mehr Volatilität) + 'london': 1.2, + 'overlap': 1.3 + } +) + +print("✅ Enhanced Trailing Stop Manager activated!") +``` + +**Update Scheduler:** + +```python +# Remove old trailing stop (if exists) +try: + scheduler.remove_job('advanced_position_management') +except: + pass + +# Add enhanced version +enhanced_monitor = create_enhanced_position_monitor( + enhanced_trailing, + rhythm_manager, + symbol="XAUUSD" +) + +scheduler.add_job( + func=enhanced_monitor, + trigger='interval', + minutes=1, + id='enhanced_trailing_stop' +) + +print("✅ Enhanced Trailing Stop scheduled (checks every 1 min)") +``` + +--- + +### Option E: Alle 3 kombiniert (EMPFOHLEN!) + +**Cell 1: Setup alle 3 Module** ```python # ========================================== @@ -201,6 +291,7 @@ execute_trade_v2_adaptive( from dynamic_threshold_optimizer import DynamicThresholdOptimizer, auto_optimize_thresholds from enhanced_signal_scoring import EnhancedSignalScorer +from enhanced_trailing_stop import EnhancedTrailingStopManager, create_enhanced_position_monitor print("🚀 INITIALIZING ADVANCED OPTIMIZATIONS...") print("=" * 70) @@ -227,15 +318,31 @@ signal_scorer = EnhancedSignalScorer( } ) print("✅ Enhanced Signal Scorer initialized") + +# 3. Enhanced Trailing Stop +enhanced_trailing = EnhancedTrailingStopManager( + breakeven_trigger_pct=0.30, + breakeven_buffer_pips=5, + tier1_trigger=0.50, + tier1_lock_pct=0.25, + tier2_trigger=0.75, + tier2_lock_pct=0.50, + tier3_trigger=0.90, + tier3_lock_pct=0.75, + use_atr_trailing=True, + time_based_breakeven=True, + hours_to_breakeven=4.0 +) +print("✅ Enhanced Trailing Stop Manager initialized") print() -# 3. Run initial optimization +# 4. Run initial optimization print("🔄 Running initial threshold optimization...") results = auto_optimize_thresholds(threshold_optimizer, apply_changes=True) print() print("=" * 70) -print("🎯 ADVANCED OPTIMIZATIONS ACTIVE!") +print("🎯 ALL ADVANCED OPTIMIZATIONS ACTIVE!") print("=" * 70) ``` @@ -316,15 +423,36 @@ adaptive_trading_check = adaptive_trading_check_optimized **Cell 3: Add Scheduler Jobs** ```python -# Auto-optimize thresholds daily +# 1. Auto-optimize thresholds daily scheduler.add_job( func=lambda: auto_optimize_thresholds(threshold_optimizer, apply_changes=True), trigger='cron', hour=0, # Midnight UTC id='threshold_optimization' ) +print("✅ Threshold optimization scheduled (daily at midnight)") -print("✅ Scheduler updated with auto-optimization") +# 2. Enhanced trailing stop monitor +# Remove old version if exists +try: + scheduler.remove_job('advanced_position_management') +except: + pass + +# Add enhanced version +enhanced_monitor = create_enhanced_position_monitor( + enhanced_trailing, + rhythm_manager, + symbol="XAUUSD" +) + +scheduler.add_job( + func=enhanced_monitor, + trigger='interval', + minutes=1, + id='enhanced_trailing_stop' +) +print("✅ Enhanced trailing stop scheduled (every 1 min)") ``` ---