# ๐Ÿ–ฅ๏ธ Trading Bot GUI - Desktop Application ## รœberblick Eine professionelle **Tkinter Desktop-Anwendung** fรผr den Trading Bot V1.9. ### Features โœ… **MT5 Connection Management** - One-Click MT5 Verbindung - Live Account Status - Balance Anzeige โœ… **Bot Controls** - Start/Stop Bot mit einem Klick - Live Bot Status - Session Filter Konfiguration โœ… **Real-time Monitoring** - Current Session Display - Adaptive Interval Anzeige - Position Count - Daily P/L โœ… **Drawdown Protection Status** - Live Loss Limits - Consecutive Loss Counter - Trading Status (Allowed/Paused) โœ… **Manual Controls** - Status Check - Position Check - Close All Positions (mit Confirmation) โœ… **Activity Log** - Live Event-Log - Color-coded Messages - Scrollable History --- ## Installation ### Voraussetzungen ```bash pip install tkinter # (meist bereits mit Python installiert) pip install MetaTrader5 pip install pandas pip install pandas-ta pip install apscheduler pip install pytz ``` ### Projekt-Struktur ``` placeorder/ โ”œโ”€โ”€ trading_bot_gui.py # ๐Ÿ–ฅ๏ธ Tkinter GUI (NEU!) โ”œโ”€โ”€ adaptive_rhythm_manager.py # Adaptive Intervals (NEU!) โ”œโ”€โ”€ execute_trade.py # Trade Execution (NEU!) โ”‚ โ”œโ”€โ”€ infrastructure_patch.py # Infrastructure โ”œโ”€โ”€ trading_database.py # Database โ”œโ”€โ”€ telegram_notifier.py # Telegram โ”œโ”€โ”€ position_monitor.py # Position Monitor โ”œโ”€โ”€ session_filter_patch.py # Session Filter โ”œโ”€โ”€ drawdown_protection.py # Drawdown Protection โ”‚ โ””โ”€โ”€ trading_bot.db # SQLite Database ``` --- ## ๐Ÿš€ Starten der GUI ### Option 1: Direkt starten ```bash python trading_bot_gui.py ``` ### Option 2: Als ausfรผhrbare Datei (Windows) ```bash # Mit PyInstaller: pip install pyinstaller pyinstaller --onefile --windowed \ --name "TradingBot" \ --icon=icon.ico \ trading_bot_gui.py ``` Dann findest du `TradingBot.exe` im `dist/` Ordner. --- ## ๐Ÿ“– Bedienungsanleitung ### 1๏ธโƒฃ MT5 Verbindung herstellen 1. Klicke auf **"Connect to MT5"** 2. Warte bis Status **"โœ… Connected"** angezeigt wird 3. Account-Info wird angezeigt ### 2๏ธโƒฃ Bot starten 1. Stelle sicher MT5 ist verbunden 2. Klicke auf **"โ–ถ๏ธ Start Bot"** 3. Bot Status รคndert sich zu **"โœ… Bot Running"** 4. Trading beginnt automatisch ### 3๏ธโƒฃ Session Filter anpassen **Wรคhrend der Laufzeit รคnderbar!** - โ˜‘๏ธ **Asian**: An/Aus - โ˜‘๏ธ **London**: An/Aus - โ˜‘๏ธ **Overlap**: An/Aus - โ˜‘๏ธ **NY**: An/Aus **Confidence Threshold:** - Slider: 50% - 90% - Empfohlen: 70% (aktuell) ### 4๏ธโƒฃ Status รผberwachen **Trading Status Panel zeigt:** - ๐Ÿ“Š Current Session (Asian/London/NY/Overlap) - โฑ๏ธ Adaptive Interval (5/15/30 min) - ๐Ÿ“ˆ Open Positions (0/1) - ๐Ÿ’ฐ Daily P/L **Drawdown Protection Panel:** - โœ…/๐Ÿ›‘ Trading Status - Daily Loss: $X / $100 - Consecutive Losses: X / 5 ### 5๏ธโƒฃ Manuelle Kontrollen **Check Status:** - Aktualisiert alle Anzeigen - Prรผft Drawdown Protection - Zeigt aktuelle Metriken **Check Positions:** - Zeigt alle offenen Positionen im Log - Ticket, Typ, P/L **Close All Positions:** - โš ๏ธ SchlieรŸt ALLE Positionen! - Confirmation-Dialog - Nur fรผr Notfรคlle! ### 6๏ธโƒฃ Activity Log **Alle Events werden geloggt:** - โœ… Success Messages (grรผn) - โ„น๏ธ Info Messages - โš ๏ธ Warnings - โŒ Errors (rot) **Clear Log:** - Klick auf "๐Ÿ—‘๏ธ Clear Log" um Log zu leeren ### 7๏ธโƒฃ Bot stoppen 1. Klicke auf **"โน๏ธ Stop Bot"** 2. Scheduler wird gestoppt 3. Offene Positionen bleiben **bestehen**! 4. Bot Status รคndert sich zu **"โธ๏ธ Bot Stopped"** --- ## โš™๏ธ Konfiguration ### Session Filter (Live รคnderbar!) ```python # Im GUI einfach Checkboxen an/abwรคhlen โœ… Asian = True/False โœ… London = True/False โœ… Overlap = True/False โœ… NY = True/False ``` ### Confidence Threshold ```python # Slider: 50 - 90 Empfohlen: 70 ``` ### Drawdown Protection **Limits sind hardcoded in `drawdown_protection.py`:** ```python max_daily_loss = 100 # $100/Tag max_weekly_loss = 300 # $300/Woche max_monthly_loss = 800 # $800/Monat max_consecutive_losses = 5 # 5 Verluste in Folge cooldown_hours = 24 # 24h Pause ``` **Zum ร„ndern:** - ร–ffne `drawdown_protection.py` - Passe `create_protected_trading_check()` an (Zeile 294-302) --- ## ๐ŸŽจ GUI Layout ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ ๐Ÿค– Trading Bot V1.9 - Control Center โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ ๐Ÿ“ก MT5 Connection โ”‚ ๐Ÿ“ˆ Trading Status โ”‚ โ”‚ โœ… Connected โ”‚ Session: NY โ”‚ โ”‚ Account: 10800246 โ”‚ Interval: 15 min โ”‚ โ”‚ Balance: $7166.38 โ”‚ Positions: 0/1 โ”‚ โ”‚ โ”‚ Daily P/L: $0.00 โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ ๐Ÿค– Bot Controls โ”‚ ๐Ÿ“‹ Activity Log โ”‚ โ”‚ โœ… Bot Running โ”‚ [00:15:23] INFO: Bot started โ”‚ โ”‚ [โ–ถ๏ธ Start] โ”‚ [00:15:45] INFO: Connected to MT5 โ”‚ โ”‚ [โน๏ธ Stop] โ”‚ [00:16:12] INFO: Position opened โ”‚ โ”‚ โ”‚ ... โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค [๐Ÿ—‘๏ธ Clear Log] โ”‚ โ”‚ ๐Ÿ“Š Session Filter โ”‚ โ”‚ โ”‚ โ˜‘ Asian โ”‚ โ”‚ โ”‚ โ˜ London โ”‚ โ”‚ โ”‚ โ˜ Overlap โ”‚ โ”‚ โ”‚ โ˜‘ NY โ”‚ โ”‚ โ”‚ Confidence: 70% โ”‚ โ”‚ โ”‚ [โ•โ•โ•โ•โ•โ•โ•70โ•โ•โ•] โ”‚ โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”‚ ๐Ÿ›ก๏ธ Drawdown Protect โ”‚ โ”‚ โ”‚ โœ… Trading Allowed โ”‚ โ”‚ โ”‚ Daily: $0/$100 โ”‚ โ”‚ โ”‚ Consecutive: 0/5 โ”‚ โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”‚ ๐ŸŽฎ Manual Controls โ”‚ โ”‚ โ”‚ [๐Ÿ“Š Check Status] โ”‚ โ”‚ โ”‚ [๐Ÿ”„ Check Pos] โ”‚ โ”‚ โ”‚ [โŒ Close All] โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ ``` --- ## ๐Ÿ›ก๏ธ Sicherheitshinweise ### โš ๏ธ WICHTIG: 1. **Close All Positions** nur in Notfรคllen! - Confirmation-Dialog wird angezeigt - SchlieรŸt wirklich ALLE Positionen 2. **Bot Stop** beendet nur den Scheduler - Offene Positionen bleiben bestehen - Position Monitor lรคuft weiter bis GUI geschlossen wird 3. **Session Filter ร„nderungen** wirken sofort - Bot รผbernimmt neue Config im nรคchsten Interval - Keine Bestรคtigung nรถtig 4. **Drawdown Protection** arbeitet automatisch - Pausiert Trading bei Limit-รœberschreitung - Telegram Notification wird gesendet - Auto-Resume nach Cooldown --- ## ๐Ÿ› Troubleshooting ### Problem: "MT5 initialization failed" **Lรถsung:** - MetaTrader 5 muss laufen - Algo-Trading muss aktiviert sein (Tools โ†’ Options โ†’ Expert Advisors) ### Problem: "Bot starting error: execute_trade_v2_adaptive not found" **Lรถsung:** - `execute_trade.py` ist ein Placeholder - Du musst die komplette Trade-Logik aus dem Notebook extrahieren - Siehe Abschnitt "Vollstรคndige Integration" unten ### Problem: GUI friert ein **Lรถsung:** - Alle langen Operationen laufen in Threads - Wenn GUI einfriert: Force-Close und neu starten - Check Log fรผr Fehler ### Problem: Drawdown Status nicht sichtbar **Lรถsung:** - Bot muss gestartet sein - Klick auf "Check Status" um zu aktualisieren --- ## ๐Ÿ”ง Vollstรคndige Integration (TODO) **Die GUI ist aktuell ein Framework!** Um voll funktionsfรคhig zu sein, musst du noch folgendes tun: ### 1. Trade Execution Module vervollstรคndigen Extrahiere aus Notebook: - `extended_top_down_v2_adaptive()` - `check_existing_positions()` - `market_order()` - `check_risk_limits()` - Alle Helper Functions ### 2. Market Analysis Module erstellen ```python # market_analysis.py def detect_market_regime(df, lookback=50): # ... aus Notebook def get_enhanced_trend(timeframe, lookback, symbol): # ... aus Notebook ``` ### 3. Imports anpassen In `trading_bot_gui.py`: ```python from execute_trade import ( execute_trade_v2_adaptive, check_existing_positions, close_existing_positions ) from market_analysis import ( extended_top_down_v2_adaptive, detect_market_regime ) ``` --- ## ๐Ÿ’ก Vorteile der GUI ### vs. Jupyter Notebook: โœ… **Benutzerfreundlichkeit** - Keine Code-Kenntnisse nรถtig zum Bedienen - Buttons statt Code ausfรผhren - Live Status-Anzeige โœ… **Stabilitรคt** - Keine Kernel-Crashes - Thread-safe Operations - Exception Handling โœ… **Deployment** - Als .exe fรผr Windows - Keine Jupyter Installation nรถtig - Standalone-App ### vs. Web Dashboard: โœ… **Kontrolle** - Start/Stop Bot direkt - Session Config รคndern - Direkte MT5-Verbindung โœ… **Lokal** - Keine Server nรถtig - Lรคuft auf Windows-PC - Kein Port-Forwarding ### Kombination empfohlen: ``` Desktop PC: โ””โ”€โ”€ trading_bot_gui.py # Kontrolle + Monitoring VPS: โ””โ”€โ”€ trading_bot_service.py # 24/7 Trading โ””โ”€โ”€ trading_dashboard.py # Web Monitoring ``` --- ## ๐Ÿ“ˆ Nรคchste Schritte 1. **Trade Execution vervollstรคndigen** - Module aus Notebook extrahieren - Alle Dependencies auflรถsen 2. **Testing** - GUI auf Demo-Account testen - Alle Buttons durchklicken - Error-Handling prรผfen 3. **Deployment** - PyInstaller .exe erstellen - Icon hinzufรผgen - Installer erstellen (NSIS) 4. **Enhancement** - Live Charts integrieren (matplotlib) - Trade History Tabelle - Performance Metrics --- ## ๐Ÿ“ž Support Bei Problemen: 1. Check Activity Log fรผr Errors 2. Check `trading_bot.db` (SQLite Browser) 3. Check Telegram Bot Messages --- **Status:** ๐ŸŸก Framework Ready - Trade Execution TODO **Version:** V1.9 GUI **Last Updated:** 2025-12-06