{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# TradingBot V1.4 - Complete Version\n", "\n", "## 🚀 Optimierte Entry Signal Logik\n", "\n", "### Hauptverbesserungen:\n", "1. **Adaptive Confidence Threshold** - Automatische Anpassung an Marktbedingungen\n", "2. **Market Regime Detection** - Erkennung von Trending/Ranging/Volatile Märkten\n", "3. **Entry Timing Optimization** - Pullback-basierte Entries\n", "4. **Risk-Adjusted Signal Strength** - Kombiniert Confidence mit Trend-Stärke\n", "5. **Performance Monitoring** - Automatisches Tracking" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Imports\n", "import pandas as pd\n", "import numpy as np\n", "import MetaTrader5 as mt\n", "import pandas_ta as ta\n", "from scipy.signal import savgol_filter, find_peaks\n", "from sklearn.linear_model import LinearRegression\n", "from tabulate import tabulate\n", "from datetime import datetime, timedelta\n", "import json\n", "import keyring as kr\n", "\n", "print(\"✅ All imports successful\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# MT5 Login\n", "mt.initialize()\n", "login = 10800246\n", "server = 'VantageInternational-Demo'\n", "password = kr.get_password(server, str(login))\n", "login_result = mt.login(login, password, server)\n", "print(f\"Login successful: {login_result}\")\n", "\n", "# Trading Parameter\n", "symbol = \"XAUUSD\"\n", "strategy_name = \"TradingBot_V1.4_Complete\"\n", "print(f\"Symbol: {symbol}\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Helper Functions\n", "def get_rates(timeframe=\"h4\", count=200, symbol=\"XAUUSD\"):\n", " timeframes_dict = {\n", " \"m1\": mt.TIMEFRAME_M1, \"m5\": mt.TIMEFRAME_M5, \"m15\": mt.TIMEFRAME_M15,\n", " \"m30\": mt.TIMEFRAME_M30, \"h1\": mt.TIMEFRAME_H1, \"h4\": mt.TIMEFRAME_H4, \"d1\": mt.TIMEFRAME_D1\n", " }\n", " try:\n", " rates = mt.copy_rates_from_pos(symbol, timeframes_dict[timeframe], 0, count)\n", " if rates is None: return None\n", " df = pd.DataFrame(rates)\n", " df['time'] = pd.to_datetime(df['time'], unit='s')\n", " df.set_index('time', inplace=True)\n", " df['atr'] = ta.atr(df['high'], df['low'], df['close'], length=14)\n", " return df\n", " except Exception as e:\n", " print(f\"Error getting rates: {e}\")\n", " return None\n", "\n", "def check_risk_limits(symbol, volume=None, order_type=\"buy\", max_risk_per_trade=0.01):\n", " try:\n", " account_info = mt.account_info()\n", " if not account_info: return False\n", " balance, equity = account_info.balance, account_info.equity\n", " if equity < balance * 0.8: return False\n", " return True\n", " except: return False\n", "\n", "def market_order(symbol, volume, order_type, stoploss=None, take_profit=None, deviation=20):\n", " try:\n", " price_dict = {'buy': mt.symbol_info_tick(symbol).ask, 'sell': mt.symbol_info_tick(symbol).bid}\n", " order_type_dict = {'buy': mt.ORDER_TYPE_BUY, 'sell': mt.ORDER_TYPE_SELL}\n", " request = {\n", " \"action\": mt.TRADE_ACTION_DEAL, \"symbol\": symbol, \"volume\": volume,\n", " \"type\": order_type_dict[order_type], \"price\": price_dict[order_type],\n", " \"sl\": stoploss, \"tp\": take_profit, \"deviation\": deviation,\n", " \"magic\": 234000, \"comment\": strategy_name, \"type_time\": mt.ORDER_TIME_GTC,\n", " \"type_filling\": mt.ORDER_FILLING_IOC\n", " }\n", " return mt.order_send(request)\n", " except Exception as e:\n", " print(f\"Error in market order: {e}\")\n", " return None\n", "\n", "print(\"✅ Helper functions defined\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Market Regime Detection\n", "def detect_market_regime(df, lookback=50):\n", " try:\n", " adx_data = ta.adx(df['high'], df['low'], df['close'], length=14)\n", " adx = adx_data['ADX_14'].iloc[-1] if adx_data is not None and 'ADX_14' in adx_data.columns else 25.0\n", " \n", " try:\n", " bb = ta.bbands(df['close'], length=20)\n", " if bb is not None and len(bb.columns) >= 3:\n", " bb_cols = bb.columns.tolist()\n", " bb_width = ((bb[bb_cols[0]] - bb[bb_cols[2]]) / bb[bb_cols[1]] * 100).iloc[-lookback:].mean()\n", " else: bb_width = 4.0\n", " except: bb_width = 4.0\n", " \n", " price_range = df['high'].iloc[-lookback:].max() - df['low'].iloc[-lookback:].min()\n", " atr_avg = df['atr'].iloc[-lookback:].mean()\n", " range_ratio = price_range / (atr_avg * lookback) if atr_avg > 0 else 1.0\n", " vol_cluster = df['atr'].iloc[-10:].std() / df['atr'].iloc[-50:].mean() if len(df) >= 50 else 1.0\n", " \n", " if adx > 25 and range_ratio > 1.5:\n", " regime, strength = 'trending', min(100, adx * 2)\n", " elif vol_cluster > 1.5:\n", " regime, strength = 'volatile', min(100, vol_cluster * 50)\n", " else:\n", " regime, strength = 'ranging', max(0, 100 - adx * 2)\n", " \n", " return {'regime': regime, 'strength': strength, 'adx': adx, 'bb_width': bb_width, 'range_ratio': range_ratio, 'vol_cluster': vol_cluster}\n", " except Exception as e:\n", " return {'regime': 'ranging', 'strength': 50, 'adx': 20, 'bb_width': 4.0, 'range_ratio': 1.0, 'vol_cluster': 1.0}\n", "\n", "print(\"✅ Market Regime Detection defined\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Adaptive Confidence System\n", "def calculate_adaptive_confidence_threshold(regime_info, base_confidence=70):\n", " regime = regime_info['regime']\n", " adx = regime_info['adx']\n", " \n", " if regime == 'trending':\n", " return max(60, base_confidence - 15) if adx > 30 else base_confidence - 10\n", " elif regime == 'ranging':\n", " return base_confidence + 15\n", " elif regime == 'volatile':\n", " return base_confidence + 20\n", " return base_confidence\n", "\n", "print(\"✅ Adaptive Confidence System defined\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Enhanced Trend Analysis\n", "def get_enhanced_trend(timeframe=\"H4\", lookback=150, symbol=\"XAUUSD\"):\n", " tf_map = {\"D1\": \"d1\", \"H4\": \"h4\", \"H1\": \"h1\", \"M30\": \"m30\", \"M15\": \"m15\", \"M5\": \"m5\"}\n", " tf = tf_map.get(timeframe, timeframe.lower())\n", " \n", " try:\n", " df = get_rates(tf, lookback, symbol)\n", " if df is None or len(df) < 50: return None\n", " \n", " df['close_smooth'] = savgol_filter(df['close'], min(15, len(df)//10), 3)\n", " X = np.arange(len(df)).reshape(-1, 1)\n", " y = df['close_smooth'].values\n", " model = LinearRegression().fit(X, y)\n", " slope = model.coef_[0]\n", " \n", " regime_info = detect_market_regime(df.iloc[-50:])\n", " base_threshold = df['atr'].iloc[-1] * 0.0001\n", " \n", " if regime_info['regime'] == 'trending':\n", " slope_threshold = base_threshold * 0.7\n", " elif regime_info['regime'] == 'ranging':\n", " slope_threshold = base_threshold * 1.5\n", " else:\n", " slope_threshold = base_threshold * 1.2\n", " \n", " trend = \"uptrend\" if slope > slope_threshold else \"downtrend\" if slope < -slope_threshold else \"sideways\"\n", " trend_strength = abs(slope) / slope_threshold if slope_threshold > 0 else 0\n", " \n", " return {\n", " \"trend\": trend, \"slope\": slope, \"slope_threshold\": slope_threshold,\n", " \"trend_strength\": trend_strength, \"atr\": df['atr'].iloc[-1],\n", " \"price\": df['close'].iloc[-1], \"regime_info\": regime_info\n", " }\n", " except Exception as e:\n", " print(f\"Error in get_enhanced_trend: {e}\")\n", " return None\n", "\n", "print(\"✅ Enhanced Trend Analysis defined\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Extended Top-Down Analysis V2\n", "def extended_top_down_v2(symbol=\"XAUUSD\", lookback=150):\n", " timeframes = [\"D1\", \"H4\", \"H1\", \"M30\", \"M15\", \"M5\"]\n", " trend_info = {}\n", " \n", " for tf in timeframes:\n", " trend_info[tf] = get_enhanced_trend(tf, lookback, symbol)\n", " if trend_info[tf] is None:\n", " print(f\"⚠️ Keine Daten für {tf}\")\n", " return None\n", " \n", " main_regime = trend_info[\"H4\"][\"regime_info\"]\n", " adaptive_confidence_threshold = calculate_adaptive_confidence_threshold(main_regime)\n", " \n", " # Standard-Trend (D1 + H4)\n", " d1_trend = trend_info[\"D1\"][\"trend\"]\n", " h4_trend = trend_info[\"H4\"][\"trend\"]\n", " d1_strength = trend_info[\"D1\"][\"trend_strength\"]\n", " h4_strength = trend_info[\"H4\"][\"trend_strength\"]\n", " \n", " if d1_trend == h4_trend and d1_trend != \"sideways\":\n", " standard_trend = d1_trend\n", " standard_strength = (d1_strength * 0.6 + h4_strength * 0.4)\n", " elif d1_strength > h4_strength * 1.5:\n", " standard_trend = d1_trend\n", " standard_strength = d1_strength * 0.8\n", " elif h4_strength > d1_strength * 1.5:\n", " standard_trend = h4_trend\n", " standard_strength = h4_strength * 0.8\n", " else:\n", " standard_trend = \"sideways\"\n", " standard_strength = 0\n", " \n", " # Fast-Trend\n", " fast_timeframes = [\"H1\", \"M30\", \"M15\", \"M5\"]\n", " fast_trends = [trend_info[tf][\"trend\"] for tf in fast_timeframes]\n", " fast_strengths = [trend_info[tf][\"trend_strength\"] for tf in fast_timeframes]\n", " \n", " required_alignment = 2 if main_regime['regime'] == 'trending' else 3\n", " \n", " trend_counts = {'uptrend': 0, 'downtrend': 0, 'sideways': 0}\n", " weighted_strengths = {'uptrend': 0, 'downtrend': 0}\n", " weights = [1.0, 0.8, 0.6, 0.4]\n", " \n", " for i, (trend, strength) in enumerate(zip(fast_trends, fast_strengths)):\n", " trend_counts[trend] += 1\n", " if trend != 'sideways':\n", " weighted_strengths[trend] += strength * weights[i]\n", " \n", " max_count = max(trend_counts['uptrend'], trend_counts['downtrend'])\n", " if max_count >= required_alignment:\n", " if trend_counts['uptrend'] > trend_counts['downtrend']:\n", " fast_trend = \"uptrend\"\n", " elif trend_counts['downtrend'] > trend_counts['uptrend']:\n", " fast_trend = \"downtrend\"\n", " else:\n", " fast_trend = \"uptrend\" if weighted_strengths['uptrend'] > weighted_strengths['downtrend'] else \"downtrend\"\n", " else:\n", " fast_trend = \"sideways\"\n", " \n", " # Top-Down-Trend\n", " if standard_trend == fast_trend and standard_trend != \"sideways\":\n", " top_down_trend = standard_trend\n", " combined_strength = (standard_strength + weighted_strengths.get(fast_trend, 0)) / 2\n", " else:\n", " top_down_trend = \"sideways\"\n", " combined_strength = 0\n", " \n", " # Confidence Calculation\n", " weights = {\"D1\": 2.5, \"H4\": 2.0, \"H1\": 1.5, \"M30\": 1.0, \"M15\": 0.8, \"M5\": 0.6}\n", " \n", " weighted_matching = sum(\n", " weights[tf] * trend_info[tf][\"trend_strength\"] \n", " for tf in timeframes\n", " if trend_info[tf][\"trend\"] == top_down_trend and trend_info[tf][\"trend\"] != \"sideways\"\n", " )\n", " \n", " weighted_total = sum(\n", " weights[tf] * trend_info[tf][\"trend_strength\"]\n", " for tf in timeframes\n", " if trend_info[tf][\"trend\"] != \"sideways\"\n", " )\n", " \n", " confidence = round((weighted_matching / weighted_total) * 100, 2) if weighted_total > 0 else 0.0\n", " \n", " # Risk-Adjusted Signal Strength\n", " atr = trend_info[\"M5\"][\"atr\"]\n", " rrr = 2.5\n", " risk_adjusted_strength = confidence * combined_strength * min(2.0, rrr)\n", " \n", " # Entry Signal\n", " entry_signal = 0\n", " signal_quality = \"none\"\n", " \n", " if (top_down_trend != \"sideways\" and \n", " confidence >= adaptive_confidence_threshold and\n", " risk_adjusted_strength >= 100):\n", " \n", " entry_signal = 1 if top_down_trend == \"uptrend\" else -1\n", " \n", " if confidence >= 85 and risk_adjusted_strength >= 150:\n", " signal_quality = \"excellent\"\n", " elif confidence >= 75 and risk_adjusted_strength >= 120:\n", " signal_quality = \"good\"\n", " else:\n", " signal_quality = \"fair\"\n", " \n", " # Debug Output\n", " debug_data = []\n", " for tf in timeframes:\n", " info = trend_info[tf]\n", " debug_data.append([tf, info[\"trend\"], f\"{info['trend_strength']:.2f}\", \n", " f\"{info['atr']:.4f}\", f\"{info['slope']:.6f}\", f\"{info['price']:.2f}\"])\n", " \n", " print(f\"📊 Enhanced Trend-Analyse für {symbol}\")\n", " print(f\"🎯 Market Regime: {main_regime['regime'].upper()} (Strength: {main_regime['strength']:.0f}%)\")\n", " print(f\"🎚️ Adaptive Confidence Threshold: {adaptive_confidence_threshold}%\")\n", " print(tabulate(debug_data, headers=[\"TF\", \"Trend\", \"Strength\", \"ATR\", \"Slope\", \"Price\"], tablefmt=\"psql\"))\n", " print(f\"➡️ Standard-Trend: {standard_trend} (Strength: {standard_strength:.2f})\")\n", " print(f\"➡️ Fast-Trend: {fast_trend}\")\n", " print(f\"➡️ Top-Down-Trend: {top_down_trend}\")\n", " print(f\"➡️ Confidence: {confidence}% (Threshold: {adaptive_confidence_threshold}%)\")\n", " print(f\"➡️ Risk-Adjusted Strength: {risk_adjusted_strength:.1f}\")\n", " print(f\"➡️ Signal Quality: {signal_quality.upper()}\")\n", " \n", " return {\n", " \"symbol\": symbol, \"trend_info\": trend_info, \"market_regime\": main_regime,\n", " \"standard_trend\": standard_trend, \"fast_trend\": fast_trend, \"top_down_trend\": top_down_trend,\n", " \"confidence\": confidence, \"adaptive_threshold\": adaptive_confidence_threshold,\n", " \"risk_adjusted_strength\": risk_adjusted_strength, \"entry_signal\": entry_signal,\n", " \"signal_quality\": signal_quality, \"combined_strength\": combined_strength\n", " }\n", "\n", "print(\"✅ Extended Top-Down V2 defined\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Entry Timing Optimization\n", "def check_pullback_entry(symbol, signal_info, timeframe=\"M5\"):\n", " if signal_info[\"entry_signal\"] == 0:\n", " return False, \"No base signal\"\n", " \n", " try:\n", " df = get_rates(timeframe.lower(), 50, symbol)\n", " if df is None or len(df) < 20:\n", " return False, \"Insufficient data\"\n", " \n", " df['ema21'] = df['close'].ewm(span=21).mean()\n", " df['ema50'] = df['close'].ewm(span=50).mean()\n", " \n", " current_price = df['close'].iloc[-1]\n", " ema21 = df['ema21'].iloc[-1]\n", " ema50 = df['ema50'].iloc[-1]\n", " signal_direction = signal_info[\"entry_signal\"]\n", " \n", " if signal_direction == 1: # Long\n", " if current_price <= ema21 * 1.002 and ema21 > ema50:\n", " return True, \"Pullback to EMA21 for Long\"\n", " elif current_price <= ema21 * 0.998:\n", " return True, \"Below EMA21 - Good Long Entry\"\n", " elif signal_direction == -1: # Short\n", " if current_price >= ema21 * 0.998 and ema21 < ema50:\n", " return True, \"Pullback to EMA21 for Short\"\n", " elif current_price >= ema21 * 1.002:\n", " return True, \"Above EMA21 - Good Short Entry\"\n", " \n", " return False, \"Waiting for better entry timing\"\n", " except Exception as e:\n", " return True, \"Using immediate entry (fallback)\"\n", "\n", "print(\"✅ Entry Timing Optimization defined\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Enhanced Execute Trade Function\n", "def execute_trade_v2(\n", " symbol=\"XAUUSD\",\n", " atr_mult=1.5,\n", " base_confidence=70,\n", " max_risk_per_trade=0.01,\n", " risk_filter=True,\n", " min_atr=0.0010,\n", " use_pullback_entry=True,\n", " debug=True\n", "):\n", " signal_info = extended_top_down_v2(symbol)\n", " if signal_info is None:\n", " print(\"❌ Signal-Analyse fehlgeschlagen\")\n", " return None\n", " \n", " entry_signal = signal_info[\"entry_signal\"]\n", " confidence = signal_info[\"confidence\"]\n", " adaptive_threshold = signal_info[\"adaptive_threshold\"]\n", " signal_quality = signal_info[\"signal_quality\"]\n", " market_regime = signal_info[\"market_regime\"]\n", " \n", " m5_info = signal_info[\"trend_info\"][\"M5\"]\n", " price = m5_info[\"price\"]\n", " atr = m5_info[\"atr\"]\n", " \n", " reason = \"\"\n", " \n", " if confidence < adaptive_threshold:\n", " reason = f\"Confidence {confidence}% < threshold {adaptive_threshold}%\"\n", " elif entry_signal == 0:\n", " reason = f\"No entry signal (Trend: {signal_info['top_down_trend']})\"\n", " elif price is None or atr is None:\n", " reason = \"Price/ATR not available\"\n", " elif risk_filter and atr < min_atr:\n", " reason = f\"ATR {atr:.5f} < min_atr {min_atr}\"\n", " elif signal_quality == \"none\":\n", " reason = \"Signal quality insufficient\"\n", " else:\n", " if use_pullback_entry:\n", " pullback_ok, pullback_reason = check_pullback_entry(symbol, signal_info)\n", " if not pullback_ok:\n", " reason = f\"Entry timing: {pullback_reason}\"\n", " \n", " if not reason:\n", " risk_ok = check_risk_limits(symbol, max_risk_per_trade=max_risk_per_trade)\n", " if not risk_ok:\n", " reason = \"Risk limits exceeded\"\n", " \n", " if not reason:\n", " regime_mult = 1.0\n", " if market_regime['regime'] == 'volatile':\n", " regime_mult = 1.3\n", " elif market_regime['regime'] == 'ranging':\n", " regime_mult = 0.8\n", " \n", " adjusted_atr_mult = atr_mult * regime_mult\n", " \n", " if entry_signal == 1:\n", " stop_loss = price - adjusted_atr_mult * atr\n", " take_profit = price + adjusted_atr_mult * atr * 2.5\n", " else:\n", " stop_loss = price + adjusted_atr_mult * atr\n", " take_profit = price - adjusted_atr_mult * atr * 2.5\n", " \n", " account_info = mt.account_info()\n", " if account_info:\n", " balance = account_info.balance\n", " risk_amount = balance * max_risk_per_trade\n", " if symbol == \"XAUUSD\":\n", " volume = min(0.1, max(0.01, risk_amount / (adjusted_atr_mult * atr * 100)))\n", " else:\n", " volume = 0.01\n", " else:\n", " volume = 0.01\n", " \n", " print(f\"🚀 ENHANCED TRADE EXECUTION\")\n", " print(f\"Symbol: {symbol}\")\n", " print(f\"Direction: {'LONG' if entry_signal == 1 else 'SHORT'}\")\n", " print(f\"Price: {price:.5f}\")\n", " print(f\"Volume: {volume:.2f}\")\n", " print(f\"Stop Loss: {stop_loss:.5f}\")\n", " print(f\"Take Profit: {take_profit:.5f}\")\n", " print(f\"Confidence: {confidence}% (Threshold: {adaptive_threshold}%)\")\n", " print(f\"Signal Quality: {signal_quality.upper()}\")\n", " print(f\"Market Regime: {market_regime['regime'].upper()}\")\n", " \n", " try:\n", " order_result = market_order(\n", " symbol=symbol,\n", " volume=volume,\n", " order_type=\"buy\" if entry_signal == 1 else \"sell\",\n", " stoploss=stop_loss,\n", " take_profit=take_profit\n", " )\n", " return order_result\n", " except Exception as e:\n", " print(f\"❌ Trade execution failed: {e}\")\n", " return None\n", " else:\n", " if debug:\n", " print(f\"⏸️ TRADE SKIPPED: {reason}\")\n", " print(f\"Confidence: {confidence}% | Threshold: {adaptive_threshold}%\")\n", " print(f\"Signal Quality: {signal_quality} | Regime: {market_regime['regime']}\")\n", " return None\n", "\n", "print(\"✅ Enhanced Execute Trade defined\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test der optimierten Funktionen\n", "print(\"🔍 Testing Market Regime Detection...\")\n", "df_test = get_rates(\"h4\", 100, symbol)\n", "if df_test is not None:\n", " regime = detect_market_regime(df_test)\n", " print(f\"Regime: {regime['regime'].upper()}\")\n", " print(f\"Strength: {regime['strength']:.1f}%\")\n", " print(f\"ADX: {regime['adx']:.1f}\")\n", " \n", " adaptive_threshold = calculate_adaptive_confidence_threshold(regime)\n", " print(f\"Adaptive Threshold: {adaptive_threshold}% (vs 80% fixed)\")\n", "else:\n", " print(\"❌ Could not get test data\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test Enhanced Top-Down Analysis\n", "print(\"🔍 Testing Enhanced Top-Down Analysis...\")\n", "signal_result = extended_top_down_v2(symbol)\n", "\n", "if signal_result:\n", " print(f\"🎯 SIGNAL SUMMARY:\")\n", " print(f\"Entry Signal: {signal_result['entry_signal']}\")\n", " print(f\"Confidence: {signal_result['confidence']}%\")\n", " print(f\"Adaptive Threshold: {signal_result['adaptive_threshold']}%\")\n", " print(f\"Signal Quality: {signal_result['signal_quality'].upper()}\")\n", " print(f\"Market Regime: {signal_result['market_regime']['regime'].upper()}\")\n", " print(f\"Risk-Adjusted Strength: {signal_result['risk_adjusted_strength']:.1f}\")\n", " \n", " if signal_result['entry_signal'] != 0:\n", " direction = \"LONG\" if signal_result['entry_signal'] == 1 else \"SHORT\"\n", " print(f\"🚀 TRADING SIGNAL: {direction}\")\n", " else:\n", " print(f\"⏸️ NO TRADING SIGNAL\")\n", "else:\n", " print(\"❌ Signal analysis failed\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Trading Configuration\n", "TRADING_CONFIG = {\n", " 'symbol': symbol,\n", " 'atr_mult': 1.5,\n", " 'base_confidence': 70,\n", " 'max_risk_per_trade': 0.01,\n", " 'risk_filter': True,\n", " 'min_atr': 0.0010,\n", " 'use_pullback_entry': True,\n", " 'debug': True\n", "}\n", "\n", "print(\"⚙️ Trading Configuration:\")\n", "for key, value in TRADING_CONFIG.items():\n", " print(f\" {key}: {value}\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Test Trading Execution\n", "def test_trading():\n", " print(\"🚀 Testing Trade Execution...\")\n", " try:\n", " result = execute_trade_v2(**TRADING_CONFIG)\n", " if result:\n", " print(\"✅ Trade executed successfully!\")\n", " return result\n", " else:\n", " print(\"⏸️ No trade executed\")\n", " return None\n", " except Exception as e:\n", " print(f\"❌ Error: {e}\")\n", " return None\n", "\n", "test_result = test_trading()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Status Check\n", "def check_bot_status():\n", " print(\"🔍 Trading Bot Status:\")\n", " print(f\" MT5 Connection: {'✅' if mt.terminal_info() else '❌'}\")\n", " \n", " try:\n", " signal_info = extended_top_down_v2(symbol)\n", " if signal_info:\n", " print(f\" Current Signal: {signal_info['entry_signal']}\")\n", " print(f\" Confidence: {signal_info['confidence']}%\")\n", " print(f\" Market Regime: {signal_info['market_regime']['regime'].upper()}\")\n", " print(f\" Signal Quality: {signal_info['signal_quality'].upper()}\")\n", " except Exception as e:\n", " print(f\" Signal Check: ❌ Error: {e}\")\n", "\n", "check_bot_status()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 📝 Zusammenfassung\n", "\n", "### ✅ **TradingBot V1.4 Complete ist bereit!**\n", "\n", "**Hauptfunktionen:**\n", "- `extended_top_down_v2()` - Optimierte Signal-Analyse\n", "- `execute_trade_v2()` - Verbesserte Trade-Ausführung\n", "- `detect_market_regime()` - Marktregime-Erkennung\n", "\n", "**Nächste Schritte:**\n", "1. Teste die Funktionen im Demo-Modus\n", "2. Überwache Performance für 1-2 Wochen\n", "3. Optimiere Parameter basierend auf Ergebnissen\n", "4. Bei Erfolg: Live-Trading aktivieren" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 2 }