Files
Place-Order-Trading-Bot/TradingBot_V1.4_Complete_PositionControl.ipynb
T

135 KiB

TradingBot V1.4 - Mit Position Control

🛡️ Wichtige Verbesserung: Maximal 1 Trade gleichzeitig

Neue Features:

  • Position-Überprüfung vor jedem Trade
  • Maximal 1 aktive Position pro Symbol
  • Position-Management Funktionen
  • Automatische Blockierung bei bestehenden Trades
  • Position-Status Monitoring

1. Imports und Setup

In [1]:
# Imports
import pandas as pd
import numpy as np
import MetaTrader5 as mt
import pandas_ta as ta
from scipy.signal import savgol_filter, find_peaks
from sklearn.linear_model import LinearRegression
from tabulate import tabulate
from datetime import datetime, timedelta
import json
import keyring as kr

print("✅ All imports successful")
✅ All imports successful

2. MT5 Login und Setup

In [2]:
# MT5 Login
mt.initialize()
login = 10800246
server = 'VantageInternational-Demo'
password = kr.get_password(server, str(login))
login_result = mt.login(login, password, server)
print(f"Login successful: {login_result}")

# Trading Parameter
symbol = "XAUUSD"
strategy_name = "TradingBot_V1.4_PositionControl"
max_positions = 1  # WICHTIG: Maximal 1 Position

print(f"Symbol: {symbol}")
print(f"Strategy: {strategy_name}")
print(f"Max Positions: {max_positions}")
Login successful: True
Symbol: XAUUSD
Strategy: TradingBot_V1.4_PositionControl
Max Positions: 1

3. 🛡️ Position Control Functions

In [3]:
def check_existing_positions(symbol="XAUUSD", strategy_name="TradingBot_V1.4_PositionControl"):
    """
    Überprüft ob bereits Positionen für das Symbol und die Strategie existieren
    """
    try:
        # Alle Positionen für das Symbol abrufen
        positions = mt.positions_get(symbol=symbol)
        
        if positions is None:
            return False, {"count": 0, "details": []}
        
        # Filter nach Strategie-Namen im Kommentar
        strategy_positions = []
        for pos in positions:
            if strategy_name in pos.comment:
                strategy_positions.append({
                    "ticket": pos.ticket,
                    "type": "BUY" if pos.type == 0 else "SELL",
                    "volume": pos.volume,
                    "price_open": pos.price_open,
                    "profit": pos.profit,
                    "comment": pos.comment,
                    "time_open": pd.to_datetime(pos.time, unit='s')
                })
        
        has_position = len(strategy_positions) > 0
        
        position_info = {
            "count": len(strategy_positions),
            "details": strategy_positions
        }
        
        return has_position, position_info
        
    except Exception as e:
        print(f"Error checking positions: {e}")
        return False, {"count": 0, "details": []}

def get_position_summary(symbol="XAUUSD", strategy_name="TradingBot_V1.4_PositionControl"):
    """
    Gibt eine übersichtliche Zusammenfassung der aktuellen Positionen
    """
    has_position, position_info = check_existing_positions(symbol, strategy_name)
    
    print(f"\n📊 POSITION SUMMARY für {symbol}")
    print("=" * 50)
    
    if not has_position:
        print("✅ Keine aktiven Positionen - bereit für neuen Trade")
        return False
    
    print(f"⚠️ {position_info['count']} aktive Position(en) gefunden:")
    
    for i, pos in enumerate(position_info['details'], 1):
        profit_emoji = "🟢" if pos['profit'] >= 0 else "🔴"
        print(f"\n  Position {i}:")
        print(f"    Ticket: {pos['ticket']}")
        print(f"    Typ: {pos['type']}")
        print(f"    Volumen: {pos['volume']}")
        print(f"    Eröffnungspreis: {pos['price_open']}")
        print(f"    Profit: {profit_emoji} {pos['profit']:.2f}")
        print(f"    Eröffnungszeit: {pos['time_open']}")
    
    print(f"\n🛑 TRADING BLOCKIERT - Maximal 1 Position erlaubt")
    return True

print("✅ Position Control functions defined")
✅ Position Control functions defined
In [4]:
def close_existing_positions(symbol="XAUUSD", strategy_name="TradingBot_V1.4_PositionControl", force_close=False):
    """
    Schließt bestehende Positionen (optional)
    """
    has_position, position_info = check_existing_positions(symbol, strategy_name)
    
    if not has_position:
        print("✅ Keine Positionen zum Schließen")
        return True
    
    if not force_close:
        print(f"⚠️ {position_info['count']} Position(en) gefunden. Verwende force_close=True zum Schließen.")
        return False
    
    print(f"🔄 Schließe {position_info['count']} Position(en)...")
    
    success_count = 0
    for pos in position_info['details']:
        try:
            # Position schließen
            close_request = {
                "action": mt.TRADE_ACTION_DEAL,
                "symbol": symbol,
                "volume": pos['volume'],
                "type": mt.ORDER_TYPE_SELL if pos['type'] == "BUY" else mt.ORDER_TYPE_BUY,
                "position": pos['ticket'],
                "price": mt.symbol_info_tick(symbol).bid if pos['type'] == "BUY" else mt.symbol_info_tick(symbol).ask,
                "deviation": 20,
                "magic": 234000,
                "comment": f"Close {strategy_name}",
                "type_time": mt.ORDER_TIME_GTC,
                "type_filling": mt.ORDER_FILLING_IOC,
            }
            
            result = mt.order_send(close_request)
            
            if result.retcode == mt.TRADE_RETCODE_DONE:
                print(f"✅ Position {pos['ticket']} erfolgreich geschlossen")
                success_count += 1
            else:
                print(f"❌ Fehler beim Schließen von Position {pos['ticket']}: {result.comment}")
                
        except Exception as e:
            print(f"❌ Exception beim Schließen von Position {pos['ticket']}: {e}")
    
    print(f"📊 {success_count}/{len(position_info['details'])} Positionen erfolgreich geschlossen")
    return success_count == len(position_info['details'])

print("✅ Position closing function defined")
✅ Position closing function defined

📊 4. Standard Helper Functions

In [5]:
# Helper Functions (unverändert)
def get_rates(timeframe="h4", count=200, symbol="XAUUSD"):
    timeframes_dict = {
        "m1": mt.TIMEFRAME_M1, "m5": mt.TIMEFRAME_M5, "m15": mt.TIMEFRAME_M15,
        "m30": mt.TIMEFRAME_M30, "h1": mt.TIMEFRAME_H1, "h4": mt.TIMEFRAME_H4, "d1": mt.TIMEFRAME_D1
    }
    try:
        rates = mt.copy_rates_from_pos(symbol, timeframes_dict[timeframe], 0, count)
        if rates is None: return None
        df = pd.DataFrame(rates)
        df['time'] = pd.to_datetime(df['time'], unit='s')
        df.set_index('time', inplace=True)
        df['atr'] = ta.atr(df['high'], df['low'], df['close'], length=14)
        return df
    except Exception as e:
        print(f"Error getting rates: {e}")
        return None

def check_risk_limits(symbol, volume=None, order_type="buy", max_risk_per_trade=0.01):
    try:
        account_info = mt.account_info()
        if not account_info: return False
        balance, equity = account_info.balance, account_info.equity
        if equity < balance * 0.8: return False
        return True
    except: return False

def market_order(symbol, volume, order_type, stoploss=None, take_profit=None, deviation=20):
    try:
        price_dict = {'buy': mt.symbol_info_tick(symbol).ask, 'sell': mt.symbol_info_tick(symbol).bid}
        order_type_dict = {'buy': mt.ORDER_TYPE_BUY, 'sell': mt.ORDER_TYPE_SELL}
        request = {
            "action": mt.TRADE_ACTION_DEAL, "symbol": symbol, "volume": volume,
            "type": order_type_dict[order_type], "price": price_dict[order_type],
            "sl": stoploss, "tp": take_profit, "deviation": deviation,
            "magic": 234000, "comment": strategy_name, "type_time": mt.ORDER_TIME_GTC,
            "type_filling": mt.ORDER_FILLING_IOC
        }
        return mt.order_send(request)
    except Exception as e:
        print(f"Error in market order: {e}")
        return None

print("✅ Helper functions defined")
✅ Helper functions defined

5. 🔍 Market Analysis Functions

In [6]:
# Market Regime Detection (unverändert)
def detect_market_regime(df, lookback=50):
    try:
        adx_data = ta.adx(df['high'], df['low'], df['close'], length=14)
        adx = adx_data['ADX_14'].iloc[-1] if adx_data is not None and 'ADX_14' in adx_data.columns else 25.0
        
        try:
            bb = ta.bbands(df['close'], length=20)
            if bb is not None and len(bb.columns) >= 3:
                bb_cols = bb.columns.tolist()
                bb_width = ((bb[bb_cols[0]] - bb[bb_cols[2]]) / bb[bb_cols[1]] * 100).iloc[-lookback:].mean()
            else: bb_width = 4.0
        except: bb_width = 4.0
        
        price_range = df['high'].iloc[-lookback:].max() - df['low'].iloc[-lookback:].min()
        atr_avg = df['atr'].iloc[-lookback:].mean()
        range_ratio = price_range / (atr_avg * lookback) if atr_avg > 0 else 1.0
        vol_cluster = df['atr'].iloc[-10:].std() / df['atr'].iloc[-50:].mean() if len(df) >= 50 else 1.0
        
        if adx > 25 and range_ratio > 1.5:
            regime, strength = 'trending', min(100, adx * 2)
        elif vol_cluster > 1.5:
            regime, strength = 'volatile', min(100, vol_cluster * 50)
        else:
            regime, strength = 'ranging', max(0, 100 - adx * 2)
        
        return {'regime': regime, 'strength': strength, 'adx': adx, 'bb_width': bb_width, 'range_ratio': range_ratio, 'vol_cluster': vol_cluster}
    except Exception as e:
        return {'regime': 'ranging', 'strength': 50, 'adx': 20, 'bb_width': 4.0, 'range_ratio': 1.0, 'vol_cluster': 1.0}

def calculate_adaptive_confidence_threshold(regime_info, base_confidence=70):
    regime = regime_info['regime']
    adx = regime_info['adx']
    
    if regime == 'trending':
        return max(60, base_confidence - 15) if adx > 30 else base_confidence - 10
    elif regime == 'ranging':
        return base_confidence + 15
    elif regime == 'volatile':
        return base_confidence + 20
    return base_confidence

def get_enhanced_trend(timeframe="H4", lookback=150, symbol="XAUUSD"):
    tf_map = {"D1": "d1", "H4": "h4", "H1": "h1", "M30": "m30", "M15": "m15", "M5": "m5"}
    tf = tf_map.get(timeframe, timeframe.lower())
    
    try:
        df = get_rates(tf, lookback, symbol)
        if df is None or len(df) < 50: return None
            
        df['close_smooth'] = savgol_filter(df['close'], min(15, len(df)//10), 3)
        X = np.arange(len(df)).reshape(-1, 1)
        y = df['close_smooth'].values
        model = LinearRegression().fit(X, y)
        slope = model.coef_[0]
        
        regime_info = detect_market_regime(df.iloc[-50:])
        base_threshold = df['atr'].iloc[-1] * 0.0001
        
        if regime_info['regime'] == 'trending':
            slope_threshold = base_threshold * 0.7
        elif regime_info['regime'] == 'ranging':
            slope_threshold = base_threshold * 1.5
        else:
            slope_threshold = base_threshold * 1.2
        
        trend = "uptrend" if slope > slope_threshold else "downtrend" if slope < -slope_threshold else "sideways"
        trend_strength = abs(slope) / slope_threshold if slope_threshold > 0 else 0
        
        return {
            "trend": trend, "slope": slope, "slope_threshold": slope_threshold,
            "trend_strength": trend_strength, "atr": df['atr'].iloc[-1],
            "price": df['close'].iloc[-1], "regime_info": regime_info
        }
    except Exception as e:
        print(f"Error in get_enhanced_trend: {e}")
        return None

print("✅ Market analysis functions defined")
✅ Market analysis functions defined
In [7]:
# Extended Top-Down Analysis V2 (unverändert)
def extended_top_down_v2(symbol="XAUUSD", lookback=150):
    timeframes = ["D1", "H4", "H1", "M30", "M15", "M5"]
    trend_info = {}
    
    for tf in timeframes:
        trend_info[tf] = get_enhanced_trend(tf, lookback, symbol)
        if trend_info[tf] is None:
            print(f"⚠️ Keine Daten für {tf}")
            return None
    
    main_regime = trend_info["H4"]["regime_info"]
    adaptive_confidence_threshold = calculate_adaptive_confidence_threshold(main_regime)
    
    # Standard-Trend (D1 + H4)
    d1_trend = trend_info["D1"]["trend"]
    h4_trend = trend_info["H4"]["trend"]
    d1_strength = trend_info["D1"]["trend_strength"]
    h4_strength = trend_info["H4"]["trend_strength"]
    
    if d1_trend == h4_trend and d1_trend != "sideways":
        standard_trend = d1_trend
        standard_strength = (d1_strength * 0.6 + h4_strength * 0.4)
    elif d1_strength > h4_strength * 1.5:
        standard_trend = d1_trend
        standard_strength = d1_strength * 0.8
    elif h4_strength > d1_strength * 1.5:
        standard_trend = h4_trend
        standard_strength = h4_strength * 0.8
    else:
        standard_trend = "sideways"
        standard_strength = 0
    
    # Fast-Trend
    fast_timeframes = ["H1", "M30", "M15", "M5"]
    fast_trends = [trend_info[tf]["trend"] for tf in fast_timeframes]
    fast_strengths = [trend_info[tf]["trend_strength"] for tf in fast_timeframes]
    
    required_alignment = 2 if main_regime['regime'] == 'trending' else 3
    
    trend_counts = {'uptrend': 0, 'downtrend': 0, 'sideways': 0}
    weighted_strengths = {'uptrend': 0, 'downtrend': 0}
    weights = [1.0, 0.8, 0.6, 0.4]
    
    for i, (trend, strength) in enumerate(zip(fast_trends, fast_strengths)):
        trend_counts[trend] += 1
        if trend != 'sideways':
            weighted_strengths[trend] += strength * weights[i]
    
    max_count = max(trend_counts['uptrend'], trend_counts['downtrend'])
    if max_count >= required_alignment:
        if trend_counts['uptrend'] > trend_counts['downtrend']:
            fast_trend = "uptrend"
        elif trend_counts['downtrend'] > trend_counts['uptrend']:
            fast_trend = "downtrend"
        else:
            fast_trend = "uptrend" if weighted_strengths['uptrend'] > weighted_strengths['downtrend'] else "downtrend"
    else:
        fast_trend = "sideways"
    
    # Top-Down-Trend
    if standard_trend == fast_trend and standard_trend != "sideways":
        top_down_trend = standard_trend
        combined_strength = (standard_strength + weighted_strengths.get(fast_trend, 0)) / 2
    else:
        top_down_trend = "sideways"
        combined_strength = 0
    
    # Confidence Calculation
    weights = {"D1": 2.5, "H4": 2.0, "H1": 1.5, "M30": 1.0, "M15": 0.8, "M5": 0.6}
    
    weighted_matching = sum(
        weights[tf] * trend_info[tf]["trend_strength"] 
        for tf in timeframes
        if trend_info[tf]["trend"] == top_down_trend and trend_info[tf]["trend"] != "sideways"
    )
    
    weighted_total = sum(
        weights[tf] * trend_info[tf]["trend_strength"]
        for tf in timeframes
        if trend_info[tf]["trend"] != "sideways"
    )
    
    confidence = round((weighted_matching / weighted_total) * 100, 2) if weighted_total > 0 else 0.0
    
    # Risk-Adjusted Signal Strength
    atr = trend_info["M5"]["atr"]
    rrr = 2.5
    risk_adjusted_strength = confidence * combined_strength * min(2.0, rrr)
    
    # Entry Signal
    entry_signal = 0
    signal_quality = "none"
    
    if (top_down_trend != "sideways" and 
        confidence >= adaptive_confidence_threshold and
        risk_adjusted_strength >= 100):
        
        entry_signal = 1 if top_down_trend == "uptrend" else -1
        
        if confidence >= 85 and risk_adjusted_strength >= 150:
            signal_quality = "excellent"
        elif confidence >= 75 and risk_adjusted_strength >= 120:
            signal_quality = "good"
        else:
            signal_quality = "fair"
    
    # Debug Output
    debug_data = []
    for tf in timeframes:
        info = trend_info[tf]
        debug_data.append([tf, info["trend"], f"{info['trend_strength']:.2f}", 
                          f"{info['atr']:.4f}", f"{info['slope']:.6f}", f"{info['price']:.2f}"])
    
    print(f"📊 Enhanced Trend-Analyse für {symbol}")
    print(f"🎯 Market Regime: {main_regime['regime'].upper()} (Strength: {main_regime['strength']:.0f}%)")
    print(f"🎚️ Adaptive Confidence Threshold: {adaptive_confidence_threshold}%")
    print(tabulate(debug_data, headers=["TF", "Trend", "Strength", "ATR", "Slope", "Price"], tablefmt="psql"))
    print(f"➡️ Standard-Trend: {standard_trend} (Strength: {standard_strength:.2f})")
    print(f"➡️ Fast-Trend: {fast_trend}")
    print(f"➡️ Top-Down-Trend: {top_down_trend}")
    print(f"➡️ Confidence: {confidence}% (Threshold: {adaptive_confidence_threshold}%)")
    print(f"➡️ Risk-Adjusted Strength: {risk_adjusted_strength:.1f}")
    print(f"➡️ Signal Quality: {signal_quality.upper()}")
    
    return {
        "symbol": symbol, "trend_info": trend_info, "market_regime": main_regime,
        "standard_trend": standard_trend, "fast_trend": fast_trend, "top_down_trend": top_down_trend,
        "confidence": confidence, "adaptive_threshold": adaptive_confidence_threshold,
        "risk_adjusted_strength": risk_adjusted_strength, "entry_signal": entry_signal,
        "signal_quality": signal_quality, "combined_strength": combined_strength
    }

print("✅ Extended Top-Down V2 defined")
✅ Extended Top-Down V2 defined

6. Entry Timing Optimization

In [8]:
# Entry Timing Optimization
def check_pullback_entry(symbol, signal_info, timeframe="M5"):
    if signal_info["entry_signal"] == 0:
        return False, "No base signal"
    
    try:
        df = get_rates(timeframe.lower(), 50, symbol)
        if df is None or len(df) < 20:
            return False, "Insufficient data"
        
        df['ema21'] = df['close'].ewm(span=21).mean()
        df['ema50'] = df['close'].ewm(span=50).mean()
        
        current_price = df['close'].iloc[-1]
        ema21 = df['ema21'].iloc[-1]
        ema50 = df['ema50'].iloc[-1]
        signal_direction = signal_info["entry_signal"]
        
        if signal_direction == 1:  # Long
            if current_price <= ema21 * 1.002 and ema21 > ema50:
                return True, "Pullback to EMA21 for Long"
            elif current_price <= ema21 * 0.998:
                return True, "Below EMA21 - Good Long Entry"
        elif signal_direction == -1:  # Short
            if current_price >= ema21 * 0.998 and ema21 < ema50:
                return True, "Pullback to EMA21 for Short"
            elif current_price >= ema21 * 1.002:
                return True, "Above EMA21 - Good Short Entry"
        
        return False, "Waiting for better entry timing"
    except Exception as e:
        return True, "Using immediate entry (fallback)"

print("✅ Entry timing functions defined")
✅ Entry timing functions defined

🚀 7. Enhanced Execute Trade mit Position Control

In [9]:
def execute_trade_v2_with_position_control(
    symbol="XAUUSD",
    atr_mult=1.5,
    base_confidence=70,
    max_risk_per_trade=0.01,
    risk_filter=True,
    min_atr=0.0010,
    use_pullback_entry=True,
    max_positions=1,  # NEU: Maximale Anzahl Positionen
    strategy_name="TradingBot_V1.4_PositionControl",
    debug=True
):
    """
    Enhanced Execute Trade mit Position-Kontrolle
    WICHTIG: Verhindert mehrfache Trades!
    """
    
    # SCHRITT 1: POSITION CHECK (WICHTIGSTER PUNKT!)
    print(f"\n🔍 POSITION CHECK für {symbol}")
    has_position, position_info = check_existing_positions(symbol, strategy_name)
    
    if has_position and position_info['count'] >= max_positions:
        if debug:
            print(f"🛑 TRADE BLOCKIERT: {position_info['count']}/{max_positions} Positionen bereits aktiv")
            for pos in position_info['details']:
                profit_emoji = "🟢" if pos['profit'] >= 0 else "🔴"
                print(f"   Position: {pos['type']} {pos['volume']} @ {pos['price_open']} | Profit: {profit_emoji} {pos['profit']:.2f}")
        return None
    
    print(f"✅ Position-Check OK: {position_info['count']}/{max_positions} Positionen")
    
    # SCHRITT 2: SIGNAL ANALYSE
    signal_info = extended_top_down_v2(symbol)
    if signal_info is None:
        print("❌ Signal-Analyse fehlgeschlagen")
        return None
    
    entry_signal = signal_info["entry_signal"]
    confidence = signal_info["confidence"]
    adaptive_threshold = signal_info["adaptive_threshold"]
    signal_quality = signal_info["signal_quality"]
    market_regime = signal_info["market_regime"]
    
    # SCHRITT 3: GET PRICE/ATR
    m5_info = signal_info["trend_info"]["M5"]
    price = m5_info["price"]
    atr = m5_info["atr"]
    
    # SCHRITT 4: ENHANCED PRE-CHECKS
    reason = ""
    
    if confidence < adaptive_threshold:
        reason = f"Confidence {confidence}% < adaptive threshold {adaptive_threshold}%"
    elif entry_signal == 0:
        reason = f"No entry signal (Trend: {signal_info['top_down_trend']}, Regime: {market_regime['regime']})"
    elif price is None or atr is None:
        reason = "Price/ATR not available"
    elif risk_filter and atr < min_atr:
        reason = f"ATR {atr:.5f} < min_atr {min_atr}"
    elif signal_quality == "none":
        reason = "Signal quality insufficient"
    else:
        # SCHRITT 5: ENTRY TIMING CHECK
        if use_pullback_entry:
            pullback_ok, pullback_reason = check_pullback_entry(symbol, signal_info)
            if not pullback_ok:
                reason = f"Entry timing: {pullback_reason}"
        
        if not reason:
            # SCHRITT 6: RISK CHECKS
            risk_ok = check_risk_limits(symbol, max_risk_per_trade=max_risk_per_trade)
            if not risk_ok:
                reason = "Risk limits exceeded"
    
    # SCHRITT 7: EXECUTE TRADE IF ALL CHECKS PASS
    if not reason:
        # FINAL POSITION CHECK vor Order (Sicherheitscheck)
        final_check, _ = check_existing_positions(symbol, strategy_name)
        if final_check:
            print(f"🛑 LAST-MINUTE BLOCK: Position wurde zwischen Checks eröffnet!")
            return None
        
        # Enhanced SL/TP calculation based on regime
        regime_mult = 1.0
        if market_regime['regime'] == 'volatile':
            regime_mult = 1.3
        elif market_regime['regime'] == 'ranging':
            regime_mult = 0.8
        
        adjusted_atr_mult = atr_mult * regime_mult
        
        if entry_signal == 1:
            stop_loss = price - adjusted_atr_mult * atr
            take_profit = price + adjusted_atr_mult * atr * 2.5
        else:
            stop_loss = price + adjusted_atr_mult * atr
            take_profit = price - adjusted_atr_mult * atr * 2.5
        
        # Dynamic Position Sizing
        account_info = mt.account_info()
        if account_info:
            balance = account_info.balance
            risk_amount = balance * max_risk_per_trade
            if symbol == "XAUUSD":
                volume = min(0.1, max(0.01, risk_amount / (adjusted_atr_mult * atr * 100)))
            else:
                volume = 0.01
        else:
            volume = 0.01
        
        # Log Enhanced Trade Info
        print(f"\n🚀 ENHANCED TRADE EXECUTION (mit Position Control)")
        print(f"Symbol: {symbol}")
        print(f"Direction: {'LONG' if entry_signal == 1 else 'SHORT'}")
        print(f"Price: {price:.5f}")
        print(f"Volume: {volume:.2f}")
        print(f"Stop Loss: {stop_loss:.5f}")
        print(f"Take Profit: {take_profit:.5f}")
        print(f"Confidence: {confidence}% (Threshold: {adaptive_threshold}%)")
        print(f"Signal Quality: {signal_quality.upper()}")
        print(f"Market Regime: {market_regime['regime'].upper()}")
        print(f"Position Limit: {position_info['count']}/{max_positions}")
        print(f"Strategy: {strategy_name}")
        
        # Execute the actual trade
        try:
            order_result = market_order(
                symbol=symbol,
                volume=volume,
                order_type="buy" if entry_signal == 1 else "sell",
                stoploss=stop_loss,
                take_profit=take_profit
            )
            
            if order_result and order_result.retcode == mt.TRADE_RETCODE_DONE:
                print(f"✅ Trade erfolgreich eröffnet! Ticket: {order_result.order}")
                
                # Verify position was created
                new_check, new_info = check_existing_positions(symbol, strategy_name)
                print(f"📊 Neue Position-Anzahl: {new_info['count']}")
            else:
                print(f"❌ Trade failed: {order_result.comment if order_result else 'No result'}")
            
            return order_result
            
        except Exception as e:
            print(f"❌ Trade execution failed: {e}")
            return None
    
    else:
        if debug:
            print(f"\n⏸️ TRADE SKIPPED: {reason}")
            print(f"Confidence: {confidence}% | Threshold: {adaptive_threshold}%")
            print(f"Signal Quality: {signal_quality} | Regime: {market_regime['regime']}")
            print(f"Positions: {position_info['count']}/{max_positions}")
        return None

print("✅ Enhanced Execute Trade mit Position Control defined")
✅ Enhanced Execute Trade mit Position Control defined

10. Performance Monitoring

In [28]:
def log_trade_performance(signal_info, order_result):
    """
    Loggt Trade-Performance für Analyse und Optimierung
    """
    trade_data = {
        'timestamp': datetime.now().isoformat(),
        'symbol': signal_info['symbol'],
        'entry_signal': signal_info['entry_signal'],
        'confidence': signal_info['confidence'],
        'adaptive_threshold': signal_info['adaptive_threshold'],
        'signal_quality': signal_info['signal_quality'],
        'market_regime': signal_info['market_regime']['regime'],
        'regime_strength': signal_info['market_regime']['strength'],
        'risk_adjusted_strength': signal_info['risk_adjusted_strength'],
        'order_result': str(order_result) if order_result else None
    }
    
    # Save to JSON file for analysis
    try:
        filename = f"trade_performance_{signal_info['symbol']}_{datetime.now().strftime('%Y%m')}.json"
        
        try:
            with open(filename, 'r') as f:
                data = json.load(f)
        except FileNotFoundError:
            data = []
        
        data.append(trade_data)
        
        with open(filename, 'w') as f:
            json.dump(data, f, indent=2)
            
    except Exception as e:
        print(f"Warning: Could not log performance data: {e}")

def analyze_performance(symbol="XAUUSD", days_back=30):
    """
    Analysiert Performance der letzten Trades
    """
    try:
        filename = f"trade_performance_{symbol}_{datetime.now().strftime('%Y%m')}.json"
        
        with open(filename, 'r') as f:
            data = json.load(f)
        
        # Filter last X days
        cutoff = datetime.now() - timedelta(days=days_back)
        recent_trades = [
            trade for trade in data 
            if datetime.fromisoformat(trade['timestamp']) > cutoff
        ]
        
        if not recent_trades:
            print(f"No trades found in last {days_back} days")
            return
        
        # Analysis
        total_trades = len(recent_trades)
        by_regime = {}
        by_confidence = {'high': 0, 'medium': 0, 'low': 0}
        by_quality = {}
        
        for trade in recent_trades:
            # By regime
            regime = trade['market_regime']
            by_regime[regime] = by_regime.get(regime, 0) + 1
            
            # By confidence
            conf = trade['confidence']
            if conf >= 85:
                by_confidence['high'] += 1
            elif conf >= 75:
                by_confidence['medium'] += 1
            else:
                by_confidence['low'] += 1
            
            # By quality
            quality = trade['signal_quality']
            by_quality[quality] = by_quality.get(quality, 0) + 1
        
        print(f"\n📊 PERFORMANCE ANALYSIS - Last {days_back} days")
        print(f"Total Trades: {total_trades}")
        print(f"\nBy Market Regime:")
        for regime, count in by_regime.items():
            print(f"  {regime.upper()}: {count} ({count/total_trades*100:.1f}%)")
        
        print(f"\nBy Confidence Level:")
        for level, count in by_confidence.items():
            print(f"  {level.upper()}: {count} ({count/total_trades*100:.1f}%)")
        
        print(f"\nBy Signal Quality:")
        for quality, count in by_quality.items():
            print(f"  {quality.upper()}: {count} ({count/total_trades*100:.1f}%)")
            
    except Exception as e:
        print(f"Could not analyze performance: {e}")

print("✅ Performance Monitoring functions defined")
✅ Performance Monitoring functions defined

🧪 Testing

In [10]:
# Test 1: Check current positions
print("🔍 Checking current positions...")
get_position_summary(symbol, strategy_name)
Out [10]:
🔍 Checking current positions...

📊 POSITION SUMMARY für XAUUSD
==================================================
✅ Keine aktiven Positionen - bereit für neuen Trade
False
In [11]:
# Test 2: Trading Configuration
TRADING_CONFIG = {
    'symbol': symbol,
    'atr_mult': 1.5,
    'base_confidence': 70,
    'max_risk_per_trade': 0.01,
    'risk_filter': True,
    'min_atr': 0.0010,
    'use_pullback_entry': True,
    'max_positions': max_positions,
    'strategy_name': strategy_name,
    'debug': True
}

print("⚙️ Trading Configuration mit Position Control:")
for key, value in TRADING_CONFIG.items():
    print(f"  {key}: {value}")
⚙️ Trading Configuration mit Position Control:
  symbol: XAUUSD
  atr_mult: 1.5
  base_confidence: 70
  max_risk_per_trade: 0.01
  risk_filter: True
  min_atr: 0.001
  use_pullback_entry: True
  max_positions: 1
  strategy_name: TradingBot_V1.4_PositionControl
  debug: True
In [12]:
# Test 3: Trading Execution mit Position Control
def test_trading_with_position_control():
    print("🚀 Testing Trade Execution mit Position Control...")
    try:
        result = execute_trade_v2_with_position_control(**TRADING_CONFIG)
        if result:
            print("\n✅ Trade executed successfully!")
            print(f"Order result: {result}")
            
            # Show updated position status
            print("\n📊 Updated Position Status:")
            get_position_summary(symbol, strategy_name)
            return result
        else:
            print("\n⏸️ No trade executed")
            return None
    except Exception as e:
        print(f"❌ Error: {e}")
        return None

test_result = test_trading_with_position_control()
🚀 Testing Trade Execution mit Position Control...

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.02 | 45.0354 |  3.75609  | 3661.17 |
| H4   | uptrend   |     994.74 | 19.6507 |  2.9321   | 3661.17 |
| H1   | uptrend   |     195.66 | 12.3655 |  0.362916 | 3661.17 |
| M30  | uptrend   |     174.23 | 11.637  |  0.304123 | 3661.17 |
| M15  | downtrend |     108.94 |  9.9801 | -0.163091 | 3661.17 |
| M5   | uptrend   |      71.17 |  8.0333 |  0.085756 | 3661.17 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 731.51)
➡️ Fast-Trend: uptrend
➡️ Top-Down-Trend: uptrend
➡️ Confidence: 97.81% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 107103.7
➡️ Signal Quality: EXCELLENT

⏸️ TRADE SKIPPED: Entry timing: Waiting for better entry timing
Confidence: 97.81% | Threshold: 85%
Signal Quality: excellent | Regime: ranging
Positions: 0/1

⏸️ No trade executed
In [13]:
# Test 4: Try trading again (should be blocked if position exists)
print("\n🧪 Testing second trade attempt (should be blocked if position exists)...")
second_test = test_trading_with_position_control()
🧪 Testing second trade attempt (should be blocked if position exists)...
🚀 Testing Trade Execution mit Position Control...

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.02 | 45.0354 |  3.75609  | 3661.17 |
| H4   | uptrend   |     994.74 | 19.6507 |  2.9321   | 3661.17 |
| H1   | uptrend   |     195.66 | 12.3655 |  0.362916 | 3661.17 |
| M30  | uptrend   |     174.23 | 11.637  |  0.304123 | 3661.17 |
| M15  | downtrend |     108.94 |  9.9801 | -0.163091 | 3661.17 |
| M5   | uptrend   |      71.17 |  8.0333 |  0.085756 | 3661.17 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 731.51)
➡️ Fast-Trend: uptrend
➡️ Top-Down-Trend: uptrend
➡️ Confidence: 97.81% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 107103.7
➡️ Signal Quality: EXCELLENT

⏸️ TRADE SKIPPED: Entry timing: Waiting for better entry timing
Confidence: 97.81% | Threshold: 85%
Signal Quality: excellent | Regime: ranging
Positions: 0/1

⏸️ No trade executed

🔧 Position Management

In [14]:
# Manual Position Management
def show_position_management_options():
    print("🔧 POSITION MANAGEMENT OPTIONS")
    print("=" * 40)
    print("1. Show current positions")
    print("2. Close all positions (manual)")
    print("3. Test new trade")
    print("\nUse the functions below:")
    print("- get_position_summary(symbol, strategy_name)")
    print("- close_existing_positions(symbol, strategy_name, force_close=True)")
    print("- execute_trade_v2_with_position_control(**TRADING_CONFIG)")

show_position_management_options()
🔧 POSITION MANAGEMENT OPTIONS
========================================
1. Show current positions
2. Close all positions (manual)
3. Test new trade

Use the functions below:
- get_position_summary(symbol, strategy_name)
- close_existing_positions(symbol, strategy_name, force_close=True)
- execute_trade_v2_with_position_control(**TRADING_CONFIG)
In [15]:
# Optional: Close existing positions (uncomment if needed)
# print("⚠️ Closing existing positions...")
# close_existing_positions(symbol, strategy_name, force_close=True)

print("💡 To close positions manually, uncomment and run the code above")
💡 To close positions manually, uncomment and run the code above
In [16]:
# Status Check mit Position Info
def check_bot_status_with_positions():
    print("🔍 Trading Bot Status mit Position Control:")
    print(f"  MT5 Connection: {'' if mt.terminal_info() else ''}")
    
    # Position Status
    has_pos, pos_info = check_existing_positions(symbol, strategy_name)
    print(f"  Active Positions: {pos_info['count']}/{max_positions}")
    print(f"  Trading Status: {'🛑 BLOCKED' if has_pos else '✅ READY'}")
    
    # Signal Status
    try:
        signal_info = extended_top_down_v2(symbol)
        if signal_info:
            print(f"  Current Signal: {signal_info['entry_signal']}")
            print(f"  Confidence: {signal_info['confidence']}%")
            print(f"  Market Regime: {signal_info['market_regime']['regime'].upper()}")
            print(f"  Signal Quality: {signal_info['signal_quality'].upper()}")
            
            would_trade = (signal_info['entry_signal'] != 0 and not has_pos)
            print(f"  Would Trade: {'✅ YES' if would_trade else '❌ NO'}")
    except Exception as e:
        print(f"  Signal Check: ❌ Error: {e}")

check_bot_status_with_positions()
🔍 Trading Bot Status mit Position Control:
  MT5 Connection: ✅
  Active Positions: 0/1
  Trading Status: ✅ READY
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.02 | 45.0354 |  3.75609  |  3661.2 |
| H4   | uptrend   |     994.74 | 19.6507 |  2.93211  |  3661.2 |
| H1   | uptrend   |     195.66 | 12.3655 |  0.362923 |  3661.2 |
| M30  | uptrend   |     174.23 | 11.637  |  0.30413  |  3661.2 |
| M15  | downtrend |     108.94 |  9.9801 | -0.163084 |  3661.2 |
| M5   | uptrend   |      71.17 |  8.0333 |  0.085763 |  3661.2 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 731.51)
➡️ Fast-Trend: uptrend
➡️ Top-Down-Trend: uptrend
➡️ Confidence: 97.81% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 107104.7
➡️ Signal Quality: EXCELLENT
  Current Signal: 1
  Confidence: 97.81%
  Market Regime: RANGING
  Signal Quality: EXCELLENT
  Would Trade: ✅ YES

14. Performance Monitoring

In [29]:
# Aktuelle Performance analysieren
print("📊 Analyzing Recent Performance...\n")
analyze_performance(symbol, days_back=7)  # Letzte 7 Tage
📊 Analyzing Recent Performance...


📊 PERFORMANCE ANALYSIS - Last 7 days
Total Trades: 20

By Market Regime:
  RANGING: 20 (100.0%)

By Confidence Level:
  HIGH: 20 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 20 (100.0%)

Automatisierung mit APScheduler

In [18]:
#optimized_trading_job()
In [19]:
# Import APScheduler
from apscheduler.schedulers.background import BackgroundScheduler

# Wrapper-Funktion für Scheduler
def optimized_trading_job():
    """
    Hauptfunktion für automatisierten Trading mit optimierter Logik
    """
    try:
        print(f"\n{pd.Timestamp.now().strftime('%Y-%m-%d %H:%M:%S')} - Running Optimized Trading Check")
        
        # Führe optimierte Trade-Analyse aus
        result = execute_trade_v2_with_position_control(**TRADING_CONFIG)
        
        if result:
            print("✅ Trade executed with optimized logic!")
        else:
            print("⏸️ No trade - waiting for better conditions")
            
        # Performance-Update alle 6 Stunden
        current_hour = pd.Timestamp.now().hour
        if current_hour % 6 == 0:  # 0, 6, 12, 18 Uhr
            analyze_performance(symbol, days_back=1)
            
    except Exception as e:
        print(f"❌ Error in optimized trading job: {e}")

# Scheduler für optimierten Trading Bot
optimized_scheduler = BackgroundScheduler()

print("⚙️ Scheduler functions defined")
⚙️ Scheduler functions defined
In [20]:
# Hinzufügen des optimierten Trading Jobs
# Läuft alle 5 Minuten während der Handelszeiten
optimized_scheduler.add_job(
    optimized_trading_job, 
    'cron', 
    year="*", 
    month="*", 
    day_of_week="mon,tue,wed,thu,fri", 
    hour='0-23', 
    minute='*/5',
    id='optimized_trading'
)

print("⚙️ Optimized Scheduler configured:")
print("  - Trading checks every 5 minutes")
print("  - Monday to Friday, 24 hours")
print("  - Enhanced signal logic active")
print("  - Performance monitoring included")
⚙️ Optimized Scheduler configured:
  - Trading checks every 5 minutes
  - Monday to Friday, 24 hours
  - Enhanced signal logic active
  - Performance monitoring included
In [21]:
# Scheduler starten
print("🚀 Starting Optimized Trading Bot...")
optimized_scheduler.start()
print("✅ Optimized Trading Bot is now running!")
🚀 Starting Optimized Trading Bot...
✅ Optimized Trading Bot is now running!
In [36]:
# Scheduler next Job
print("\n📋 Active Jobs:")
for job in optimized_scheduler.get_jobs():
    print(f"  - {job.id}: {job.next_run_time}")
📋 Active Jobs:
  - optimized_trading: 2025-09-18 15:10:00+02:00
⏰ 2025-09-18 15:10:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 49%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     563.07 | 44.6044 |  3.7673   | 3658.78 |
| H4   | uptrend   |    1060.02 | 18.6863 |  2.97118  | 3658.78 |
| H1   | uptrend   |     191.78 | 11.1073 |  0.319524 | 3658.78 |
| M30  | downtrend |      41.71 |  7.7087 | -0.048233 | 3658.78 |
| M15  | downtrend |     243.19 |  5.2914 | -0.193025 | 3658.78 |
| M5   | uptrend   |     147.06 |  3.46   |  0.076323 | 3658.78 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 761.85)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:15:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 49%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     563.06 | 44.6044 |  3.76726  | 3658.61 |
| H4   | uptrend   |    1060.01 | 18.6863 |  2.97115  | 3658.64 |
| H1   | uptrend   |     191.76 | 11.1073 |  0.319491 | 3658.64 |
| M30  | downtrend |      41.74 |  7.7087 | -0.048266 | 3658.64 |
| M15  | downtrend |     243.24 |  5.2914 | -0.193058 | 3658.64 |
| M5   | uptrend   |     148.17 |  3.4286 |  0.076204 | 3658.64 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 761.84)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:20:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 49%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     563.07 | 44.6044 |  3.7673   | 3658.81 |
| H4   | uptrend   |    1060.03 | 18.6863 |  2.97119  | 3658.82 |
| H1   | uptrend   |     191.79 | 11.1073 |  0.319533 | 3658.82 |
| M30  | downtrend |      41.7  |  7.7087 | -0.048223 | 3658.82 |
| M15  | downtrend |     247.52 |  5.1298 | -0.190458 | 3658.82 |
| M5   | uptrend   |     150.21 |  3.4001 |  0.076611 | 3658.82 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 761.85)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:25:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 49%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     562.96 | 44.6044 |  3.76656  | 3655.68 |
| H4   | uptrend   |    1054.16 | 18.7855 |  2.97045  | 3655.68 |
| H1   | uptrend   |     189.64 | 11.2066 |  0.318791 | 3655.68 |
| M30  | downtrend |      41.81 |  7.8079 | -0.048967 | 3655.67 |
| M15  | downtrend |     235.56 |  5.4113 | -0.191202 | 3655.67 |
| M5   | uptrend   |     146.52 |  3.4965 |  0.076846 | 3655.67 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 759.44)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:30:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 48%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     562.9  | 44.6044 |  3.76614  |  3653.9 |
| H4   | uptrend   |    1044.44 | 18.9577 |  2.97003  |  3653.9 |
| H1   | uptrend   |     186.53 | 11.3788 |  0.318371 |  3653.9 |
| M30  | downtrend |      41.26 |  7.9801 | -0.049386 |  3653.9 |
| M15  | downtrend |     228.8  |  5.5834 | -0.191621 |  3653.9 |
| M5   | uptrend   |     145.14 |  3.5318 |  0.076892 |  3653.9 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 755.51)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:35:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 48%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     562.66 | 44.6044 |  3.76458  | 3647.27 |
| H4   | uptrend   |    1024.36 | 19.3191 |  2.96846  | 3647.27 |
| H1   | uptrend   |     179.9  | 11.7402 |  0.316804 | 3647.27 |
| M30  | downtrend |      53.92 |  7.9879 | -0.064612 | 3647.27 |
| M15  | downtrend |     221.32 |  5.7625 | -0.191301 | 3647.34 |
| M5   | uptrend   |     128.89 |  3.8574 |  0.074576 | 3647.34 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 747.34)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:40:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     562.43 | 44.6044 |  3.76301  | 3640.62 |
| H4   | uptrend   |     993.23 | 19.9141 |  2.96689  | 3640.62 |
| H1   | uptrend   |     170.37 | 12.3352 |  0.315233 | 3640.62 |
| M30  | downtrend |      51.41 |  8.5829 | -0.066183 | 3640.62 |
| M15  | downtrend |     202.26 |  6.3575 | -0.192882 | 3640.65 |
| M5   | uptrend   |     108.88 |  4.2826 |  0.069944 | 3640.65 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 734.75)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:45:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     558.4  | 44.8958 |  3.76046  | 3629.86 |
| H4   | uptrend   |     962.82 | 20.5255 |  2.96435  | 3629.86 |
| H1   | uptrend   |     161.02 | 12.9466 |  0.312691 | 3629.86 |
| M30  | downtrend |      49.83 |  9.1944 | -0.068718 | 3629.89 |
| M15  | downtrend |     186.95 |  6.9689 | -0.195424 | 3629.89 |
| M5   | uptrend   |      87.84 |  4.7624 |  0.062751 | 3629.89 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 720.17)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:50:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.93 | 45.0322 |  3.76194  | 3636.1  |
| H4   | uptrend   |     956.93 | 20.662  |  2.96582  | 3636.1  |
| H1   | uptrend   |     160.09 | 13.083  |  0.314165 | 3636.1  |
| M30  | downtrend |      48.05 |  9.3308 | -0.067251 | 3636.1  |
| M15  | downtrend |     184.72 |  7.1418 | -0.197885 | 3636.1  |
| M5   | uptrend   |      67.18 |  4.732  |  0.047681 | 3636.14 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 716.93)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 15:55:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.9  | 45.0322 |  3.76174  | 3635.25 |
| H4   | uptrend   |     956.87 | 20.662  |  2.96562  | 3635.25 |
| H1   | uptrend   |     159.99 | 13.083  |  0.313971 | 3635.28 |
| M30  | downtrend |      48.19 |  9.3308 | -0.067445 | 3635.28 |
| M15  | downtrend |     176.72 |  7.4726 | -0.198079 | 3635.28 |
| M5   | uptrend   |      60.57 |  5.2256 |  0.047478 | 3635.28 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 716.89)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:00:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.14 | 45.0322 |  3.76337  | 3642.18 |
| H4   | uptrend   |     957.4  | 20.662  |  2.96726  | 3642.18 |
| H1   | uptrend   |     160.82 | 13.083  |  0.315602 | 3642.18 |
| M30  | downtrend |      47.02 |  9.3308 | -0.065815 | 3642.18 |
| M15  | downtrend |     174.23 |  7.5168 | -0.196449 | 3642.18 |
| M5   | uptrend   |      50.97 |  5.4437 |  0.041619 | 3642.17 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.24)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:05:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.26 | 45.0322 |  3.76419  | 3645.64 |
| H4   | uptrend   |     957.66 | 20.662  |  2.96807  | 3645.64 |
| H1   | uptrend   |     163.61 | 12.4943 |  0.306628 | 3645.64 |
| M30  | downtrend |      60.79 |  9.01   | -0.082152 | 3645.64 |
| M15  | downtrend |     179.1  |  7.3256 | -0.196798 | 3645.64 |
| M5   | uptrend   |      43.68 |  5.017  |  0.032869 | 3645.61 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.42)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:10:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.09 | 45.0322 |  3.76304  | 3640.77 |
| H4   | uptrend   |     957.29 | 20.662  |  2.96692  | 3640.77 |
| H1   | uptrend   |     160.37 | 12.6986 |  0.305477 | 3640.77 |
| M30  | downtrend |      60.27 |  9.2143 | -0.083303 | 3640.77 |
| M15  | downtrend |     175.25 |  7.5299 | -0.197949 | 3640.77 |
| M5   | uptrend   |      38.08 |  5.5548 |  0.031726 | 3640.77 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.17)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:15:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.09 | 45.0322 |  3.76304  | 3640.78 |
| H4   | uptrend   |     957.29 | 20.662  |  2.96693  | 3640.78 |
| H1   | uptrend   |     160.38 | 12.6986 |  0.30548  | 3640.78 |
| M30  | downtrend |      60.27 |  9.2143 | -0.083301 | 3640.78 |
| M15  | downtrend |     189.58 |  6.9921 | -0.198836 | 3640.78 |
| M5   | uptrend   |      27.83 |  5.0669 |  0.021151 | 3640.78 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.17)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:20:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.97 | 45.0322 |  3.76221  | 3637.27 |
| H4   | uptrend   |     957.02 | 20.662  |  2.9661   | 3637.27 |
| H1   | uptrend   |     157.7  | 12.8793 |  0.30465  | 3637.27 |
| M30  | downtrend |      59.7  |  9.395  | -0.08413  | 3637.27 |
| M15  | downtrend |     181.2  |  7.3449 | -0.199635 | 3637.4  |
| M5   | uptrend   |      25.04 |  5.4197 |  0.020353 | 3637.4  |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 716.99)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:25:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.92 | 45.0322 |  3.76191  | 3635.99 |
| H4   | uptrend   |     956.93 | 20.662  |  2.96579  | 3635.99 |
| H1   | uptrend   |     156.16 | 12.9928 |  0.304348 | 3635.99 |
| M30  | downtrend |      59.2  |  9.5086 | -0.084432 | 3635.99 |
| M15  | downtrend |     178.74 |  7.4585 | -0.199968 | 3635.99 |
| M5   | uptrend   |      17.58 |  5.3919 |  0.014216 | 3635.99 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 716.92)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:30:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.91 | 45.0322 |  3.76182  | 3635.59 |
| H4   | uptrend   |     956.9  | 20.662  |  2.9657   | 3635.59 |
| H1   | uptrend   |     156.11 | 12.9928 |  0.304254 | 3635.59 |
| M30  | downtrend |      59.26 |  9.5086 | -0.084527 | 3635.59 |
| M15  | downtrend |     178.82 |  7.4585 | -0.200062 | 3635.59 |
| M5   | uptrend   |      10.71 |  5.2118 |  0.008372 | 3635.59 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 716.90)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:35:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     556.97 | 45.0322 |  3.76227  | 3637.51 |
| H4   | uptrend   |     957.04 | 20.662  |  2.96615  | 3637.51 |
| H1   | uptrend   |     156.35 | 12.9928 |  0.304707 | 3637.51 |
| M30  | downtrend |      74.56 |  9.1366 | -0.102182 | 3637.51 |
| M15  | downtrend |     185.56 |  7.2329 | -0.201324 | 3637.51 |
| M5   | uptrend   |       3.65 |  5.1466 |  0.002815 | 3637.52 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.00)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:40:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.17 | 45.0322 |  3.76356  | 3642.96 |
| H4   | uptrend   |     957.46 | 20.662  |  2.96744  | 3642.96 |
| H1   | uptrend   |     157.01 | 12.9928 |  0.305995 | 3642.96 |
| M30  | downtrend |      71.31 |  9.4323 | -0.100895 | 3642.96 |
| M15  | downtrend |     177.13 |  7.5286 | -0.200037 | 3642.96 |
| M5   | downtrend |       1.11 |  5.2219 | -0.00087  | 3642.96 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.28)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:45:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.13 | 45.0322 |  3.76335  | 3642.09 |
| H4   | uptrend   |     957.39 | 20.662  |  2.96724  | 3642.09 |
| H1   | uptrend   |     156.9  | 12.9928 |  0.305789 | 3642.09 |
| M30  | downtrend |      71.45 |  9.4337 | -0.10111  | 3642.05 |
| M15  | downtrend |     177.29 |  7.53   | -0.200252 | 3642.05 |
| M5   | downtrend |       5.59 |  5.0289 | -0.004215 | 3642.05 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.24)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:50:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.24 | 45.0322 |  3.76406  | 3645.09 |
| H4   | uptrend   |     957.62 | 20.662  |  2.96794  | 3645.09 |
| H1   | uptrend   |     157.08 | 13.0086 |  0.306498 | 3645.09 |
| M30  | downtrend |      69.51 |  9.6287 | -0.100391 | 3645.09 |
| M15  | downtrend |     179.32 |  7.4229 | -0.199662 | 3645.09 |
| M5   | downtrend |       8.89 |  5.1004 | -0.006799 | 3645.09 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.39)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 16:55:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.11 | 45.0322 |  3.76319  | 3641.42 |
| H4   | uptrend   |     957.34 | 20.662  |  2.96708  | 3641.42 |
| H1   | uptrend   |     156.64 | 13.0086 |  0.30565  | 3641.5  |
| M30  | downtrend |      70.1  |  9.6287 | -0.10124  | 3641.5  |
| M15  | downtrend |     180.08 |  7.4229 | -0.200511 | 3641.5  |
| M5   | downtrend |      13.06 |  5.1232 | -0.010037 | 3641.5  |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.20)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:00:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.01 | 45.0322 |  3.76248  | 3638.39 |
| H4   | uptrend   |     957.11 | 20.662  |  2.96636  | 3638.39 |
| H1   | uptrend   |     156.26 | 13.0086 |  0.304915 | 3638.39 |
| M30  | downtrend |      70.6  |  9.6287 | -0.101974 | 3638.39 |
| M15  | downtrend |     177.23 |  7.57   | -0.201245 | 3638.39 |
| M5   | downtrend |      17.73 |  5.0373 | -0.013399 | 3638.39 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.05)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:05:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.04 | 45.0322 |  3.76274  | 3639.5  |
| H4   | uptrend   |     957.19 | 20.662  |  2.96662  | 3639.5  |
| H1   | uptrend   |     159.11 | 12.3265 |  0.294189 | 3639.5  |
| M30  | downtrend |      87.21 |  9.1881 | -0.120198 | 3639.5  |
| M15  | downtrend |     184.85 |  7.2765 | -0.201754 | 3639.45 |
| M5   | downtrend |      28.07 |  4.5764 | -0.019271 | 3639.45 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.10)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:10:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.01 | 45.0322 |  3.7625   | 3638.47 |
| H4   | uptrend   |     957.11 | 20.662  |  2.96638  | 3638.47 |
| H1   | uptrend   |     158.8  | 12.3401 |  0.293946 | 3638.47 |
| M30  | downtrend |      87.26 |  9.2017 | -0.120442 | 3638.47 |
| M15  | downtrend |     184.71 |  7.2901 | -0.201986 | 3638.47 |
| M5   | downtrend |      26.99 |  4.8164 | -0.019503 | 3638.47 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.05)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:15:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.04 | 45.0322 |  3.7627   | 3639.34 |
| H4   | uptrend   |     957.18 | 20.662  |  2.96659  | 3639.34 |
| H1   | uptrend   |     157.81 | 12.4265 |  0.294151 | 3639.34 |
| M30  | downtrend |      86.3  |  9.2881 | -0.120231 | 3639.36 |
| M15  | downtrend |     197.03 |  6.851  | -0.202474 | 3639.36 |
| M5   | downtrend |      38.81 |  4.3328 | -0.025222 | 3639.36 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.10)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:20:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.1  | 45.0322 |  3.76314  | 3641.21 |
| H4   | uptrend   |     957.32 | 20.662  |  2.96703  | 3641.21 |
| H1   | uptrend   |     158.05 | 12.4265 |  0.294605 | 3641.26 |
| M30  | downtrend |      85.98 |  9.2881 | -0.119782 | 3641.26 |
| M15  | downtrend |     190.36 |  7.0753 | -0.202025 | 3641.26 |
| M5   | downtrend |      42.25 |  4.2351 | -0.026837 | 3641.26 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.19)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:25:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.06 | 45.0322 |  3.76288  | 3640.08 |
| H4   | uptrend   |     957.24 | 20.662  |  2.96676  | 3640.08 |
| H1   | uptrend   |     157.41 | 12.4651 |  0.294326 | 3640.08 |
| M30  | downtrend |      85.82 |  9.3267 | -0.120061 | 3640.08 |
| M15  | downtrend |     189.57 |  7.1146 | -0.202304 | 3640.08 |
| M5   | downtrend |      40.5  |  4.4637 | -0.027116 | 3640.08 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.13)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:30:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.04 | 45.0322 |  3.7627   | 3639.34 |
| H4   | uptrend   |     957.18 | 20.662  |  2.96659  | 3639.34 |
| H1   | uptrend   |     157.32 | 12.4651 |  0.294151 | 3639.34 |
| M30  | downtrend |      85.94 |  9.3267 | -0.120236 | 3639.34 |
| M15  | downtrend |     204.47 |  6.6203 | -0.203053 | 3639.34 |
| M5   | downtrend |      54.4  |  3.9874 | -0.032537 | 3639.34 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.10)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:35:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.05 | 45.0322 |  3.7628   | 3639.76 |
| H4   | uptrend   |     957.21 | 20.662  |  2.96669  | 3639.76 |
| H1   | uptrend   |     157.37 | 12.4651 |  0.294246 | 3639.74 |
| M30  | downtrend |     104.15 |  8.8226 | -0.137829 | 3639.74 |
| M15  | downtrend |     199.49 |  6.7825 | -0.202959 | 3639.74 |
| M5   | downtrend |      52.12 |  4.1496 | -0.032442 | 3639.74 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.12)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:40:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.08 | 45.0322 |  3.76296  | 3640.42 |
| H4   | uptrend   |     957.26 | 20.662  |  2.96684  | 3640.42 |
| H1   | uptrend   |     157.46 | 12.4651 |  0.294406 | 3640.42 |
| M30  | downtrend |     103.85 |  8.8376 | -0.137666 | 3640.43 |
| M15  | downtrend |     198.89 |  6.7975 | -0.202796 | 3640.43 |
| M5   | downtrend |      66.47 |  3.7093 | -0.036983 | 3640.43 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.15)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:45:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.07 | 45.0322 |  3.76289  | 3640.13 |
| H4   | uptrend   |     957.24 | 20.662  |  2.96677  | 3640.13 |
| H1   | uptrend   |     157.42 | 12.4651 |  0.294338 | 3640.13 |
| M30  | downtrend |     103.9  |  8.8376 | -0.137737 | 3640.13 |
| M15  | downtrend |     198.96 |  6.7975 | -0.202867 | 3640.13 |
| M5   | downtrend |      65.02 |  3.7993 | -0.037054 | 3640.13 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.14)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:50:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.07 | 45.0322 |  3.76292  | 3640.25 |
| H4   | uptrend   |     957.25 | 20.662  |  2.9668   | 3640.25 |
| H1   | uptrend   |     157.43 | 12.4651 |  0.294366 | 3640.25 |
| M30  | downtrend |     103.88 |  8.8376 | -0.137709 | 3640.25 |
| M15  | downtrend |     212.41 |  6.4155 | -0.204409 | 3640.25 |
| M5   | downtrend |      72.07 |  3.6315 | -0.039256 | 3640.25 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.14)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 17:55:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.05 | 45.0322 |  3.7628   | 3639.77 |
| H4   | uptrend   |     957.21 | 20.662  |  2.96669  | 3639.77 |
| H1   | uptrend   |     157.37 | 12.4651 |  0.294253 | 3639.77 |
| M30  | downtrend |     103.97 |  8.8376 | -0.137822 | 3639.77 |
| M15  | downtrend |     211.92 |  6.4341 | -0.204523 | 3639.77 |
| M5   | downtrend |      79.49 |  3.4885 | -0.041598 | 3639.77 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.12)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

⏰ 2025-09-18 18:00:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.11 | 45.0322 |  3.76316  | 3641.3  |
| H4   | uptrend   |     957.33 | 20.662  |  2.96705  | 3641.3  |
| H1   | uptrend   |     157.57 | 12.4651 |  0.294614 | 3641.3  |
| M30  | downtrend |     103.25 |  8.8755 | -0.13746  | 3641.3  |
| M15  | downtrend |     228.48 |  6.0488 | -0.207308 | 3641.29 |
| M5   | downtrend |      95.29 |  3.1791 | -0.045439 | 3641.29 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.20)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 17

By Market Regime:
  RANGING: 17 (100.0%)

By Confidence Level:
  HIGH: 17 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 17 (100.0%)

⏰ 2025-09-18 18:05:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.11 | 45.0322 |  3.76322  | 3641.51 |
| H4   | uptrend   |     957.35 | 20.662  |  2.9671   | 3641.51 |
| H1   | uptrend   |     162.8  | 11.7126 |  0.286017 | 3641.51 |
| M30  | downtrend |     122.35 |  8.3794 | -0.153777 | 3641.51 |
| M15  | downtrend |     223.36 |  6.186  | -0.207256 | 3641.51 |
| M5   | downtrend |     102.55 |  3.083  | -0.047423 | 3641.51 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.21)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 16

By Market Regime:
  RANGING: 16 (100.0%)

By Confidence Level:
  HIGH: 16 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 16 (100.0%)

⏰ 2025-09-18 18:10:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.13 | 45.0322 |  3.76334  | 3642.05 |
| H4   | uptrend   |     957.39 | 20.662  |  2.96723  | 3642.05 |
| H1   | uptrend   |     162.13 | 11.7662 |  0.286145 | 3642.05 |
| M30  | downtrend |     121.47 |  8.433  | -0.153649 | 3642.05 |
| M15  | downtrend |     221.31 |  6.2395 | -0.207129 | 3642.05 |
| M5   | downtrend |      97.08 |  3.248  | -0.047296 | 3642.05 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.24)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 15

By Market Regime:
  RANGING: 15 (100.0%)

By Confidence Level:
  HIGH: 15 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 15 (100.0%)

⏰ 2025-09-18 18:15:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.18 | 45.0322 |  3.76364  | 3643.33 |
| H4   | uptrend   |     957.48 | 20.662  |  2.96753  | 3643.31 |
| H1   | uptrend   |     161.65 | 11.8133 |  0.286442 | 3643.31 |
| M30  | downtrend |     120.56 |  8.4801 | -0.153352 | 3643.31 |
| M15  | downtrend |     219.33 |  6.2867 | -0.206831 | 3643.31 |
| M5   | downtrend |     102.38 |  3.1853 | -0.048918 | 3643.31 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.30)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 15

By Market Regime:
  RANGING: 15 (100.0%)

By Confidence Level:
  HIGH: 15 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 15 (100.0%)

⏰ 2025-09-18 18:20:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.23 | 45.0322 |  3.76403  | 3644.94 |
| H4   | uptrend   |     957.61 | 20.662  |  2.96791  | 3644.94 |
| H1   | uptrend   |     160.3  | 11.929  |  0.286827 | 3644.94 |
| M30  | downtrend |     118.64 |  8.5958 | -0.152966 | 3644.94 |
| M15  | downtrend |     230.48 |  6.0362 | -0.208682 | 3644.94 |
| M5   | downtrend |     106.34 |  3.1563 | -0.050348 | 3644.94 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.38)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 13

By Market Regime:
  RANGING: 13 (100.0%)

By Confidence Level:
  HIGH: 13 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 13 (100.0%)

⏰ 2025-09-18 18:25:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.21 | 45.0322 |  3.76383  |  3644.1 |
| H4   | uptrend   |     957.54 | 20.662  |  2.96771  |  3644.1 |
| H1   | uptrend   |     160.19 | 11.929  |  0.286629 |  3644.1 |
| M30  | downtrend |     118.79 |  8.5958 | -0.153165 |  3644.1 |
| M15  | downtrend |     230.7  |  6.0362 | -0.208881 |  3644.1 |
| M5   | downtrend |     113.45 |  3.0523 | -0.051941 |  3644.1 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.34)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 13

By Market Regime:
  RANGING: 13 (100.0%)

By Confidence Level:
  HIGH: 13 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 13 (100.0%)

⏰ 2025-09-18 18:30:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.21 | 45.0322 |  3.76387  | 3644.28 |
| H4   | uptrend   |     957.56 | 20.662  |  2.96775  | 3644.28 |
| H1   | uptrend   |     160.21 | 11.929  |  0.286671 | 3644.28 |
| M30  | downtrend |     118.76 |  8.5958 | -0.153122 | 3644.28 |
| M15  | downtrend |     230.65 |  6.0362 | -0.208838 | 3644.28 |
| M5   | downtrend |     122.64 |  2.9186 | -0.05369  | 3644.28 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.35)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 12

By Market Regime:
  RANGING: 12 (100.0%)

By Confidence Level:
  HIGH: 12 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 12 (100.0%)

⏰ 2025-09-18 18:35:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.22 | 45.0322 |  3.76391  | 3644.46 |
| H4   | uptrend   |     957.57 | 20.662  |  2.9678   | 3644.46 |
| H1   | uptrend   |     160.23 | 11.929  |  0.286714 | 3644.46 |
| M30  | downtrend |     140.55 |  8.0675 | -0.170081 | 3644.46 |
| M15  | downtrend |     246.59 |  5.6907 | -0.210495 | 3644.46 |
| M5   | downtrend |     133.04 |  2.7958 | -0.055794 | 3644.46 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.36)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 10

By Market Regime:
  RANGING: 10 (100.0%)

By Confidence Level:
  HIGH: 10 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 10 (100.0%)

⏰ 2025-09-18 18:40:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.22 | 45.0322 |  3.76396  | 3644.65 |
| H4   | uptrend   |     957.59 | 20.662  |  2.96784  | 3644.65 |
| H1   | uptrend   |     160.26 | 11.929  |  0.286759 | 3644.65 |
| M30  | downtrend |     140.09 |  8.0918 | -0.170036 | 3644.65 |
| M15  | downtrend |     245.49 |  5.715  | -0.21045  | 3644.65 |
| M5   | downtrend |     157.87 |  2.4819 | -0.058771 | 3644.61 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.37)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 10

By Market Regime:
  RANGING: 10 (100.0%)

By Confidence Level:
  HIGH: 10 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 10 (100.0%)

⏰ 2025-09-18 18:45:00 - Running Optimized Trading Check

🔍 POSITION CHECK für XAUUSD
✅ Position-Check OK: 0/1 Positionen
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 47%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     557.2  | 45.0322 |  3.76378  | 3643.92 |
| H4   | uptrend   |     957.53 | 20.662  |  2.96767  | 3643.92 |
| H1   | uptrend   |     160.16 | 11.929  |  0.286591 | 3643.94 |
| M30  | downtrend |     140.14 |  8.0968 | -0.170204 | 3643.94 |
| M15  | downtrend |     267.51 |  5.315  | -0.213277 | 3643.94 |
| M5   | downtrend |     168.31 |  2.3957 | -0.060484 | 3643.94 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 717.33)
➡️ Fast-Trend: downtrend
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE

⏸️ TRADE SKIPPED: Confidence 0.0% < adaptive threshold 85%
Confidence: 0.0% | Threshold: 85%
Signal Quality: none | Regime: ranging
Positions: 0/1
⏸️ No trade - waiting for better conditions

📊 PERFORMANCE ANALYSIS - Last 1 days
Total Trades: 8

By Market Regime:
  RANGING: 8 (100.0%)

By Confidence Level:
  HIGH: 8 (100.0%)
  MEDIUM: 0 (0.0%)
  LOW: 0 (0.0%)

By Signal Quality:
  EXCELLENT: 8 (100.0%)

16. Monitoring & Control

In [34]:
# Status Check
def check_optimized_bot_status():
    """
    Überprüft den Status des optimierten Trading Bots
    """
    print("🔍 Optimized Trading Bot Status:")
    print(f"  MT5 Connection: {'' if mt.terminal_info() else ''}")
    print(f"  Scheduler Running: {'' if optimized_scheduler.running else ''}")
    print(f"  Active Jobs: {len(optimized_scheduler.get_jobs())}")
    
    # Aktuelle Signal-Info
    try:
        signal_info = extended_top_down_v2(symbol)
        if signal_info:
            print(f"  Current Signal: {signal_info['entry_signal']}")
            print(f"  Confidence: {signal_info['confidence']}%")
            print(f"  Market Regime: {signal_info['market_regime']['regime'].upper()}")
            print(f"  Signal Quality: {signal_info['signal_quality'].upper()}")
    except Exception as e:
        print(f"  Signal Check: ❌ Error: {e}")

check_optimized_bot_status()
🔍 Optimized Trading Bot Status:
  MT5 Connection: ✅
  Scheduler Running: ✅
  Active Jobs: 1
📊 Enhanced Trend-Analyse für XAUUSD
🎯 Market Regime: RANGING (Strength: 49%)
🎚️ Adaptive Confidence Threshold: 85%
+------+-----------+------------+---------+-----------+---------+
| TF   | Trend     |   Strength |     ATR |     Slope |   Price |
|------+-----------+------------+---------+-----------+---------|
| D1   | uptrend   |     590.14 | 42.5729 |  3.76857  | 3664.17 |
| H4   | uptrend   |    1034.27 | 19.0014 |  2.94787  | 3664.17 |
| H1   | uptrend   |     205.04 | 11.7825 |  0.362386 | 3664.17 |
| M30  | uptrend   |     172.55 | 10.7198 |  0.27746  | 3664.17 |
| M15  | downtrend |     154.69 |  8.2527 | -0.191496 | 3664.17 |
| M5   | downtrend |      33.98 |  4.0692 | -0.02074  | 3664.17 |
+------+-----------+------------+---------+-----------+---------+
➡️ Standard-Trend: uptrend (Strength: 767.79)
➡️ Fast-Trend: sideways
➡️ Top-Down-Trend: sideways
➡️ Confidence: 0.0% (Threshold: 85%)
➡️ Risk-Adjusted Strength: 0.0
➡️ Signal Quality: NONE
  Current Signal: 0
  Confidence: 0.0%
  Market Regime: RANGING
  Signal Quality: NONE

17. Control Panel

In [24]:
# Stoppe alle Jobs
# optimized_scheduler.remove_all_jobs()
# print("⏹️ All jobs removed")

print("💡 To stop trading, uncomment and run:")
print("optimized_scheduler.remove_all_jobs()")
💡 To stop trading, uncomment and run:
optimized_scheduler.remove_all_jobs()
In [33]:
# Scheduler herunterfahren
# optimized_scheduler.shutdown()
# print("🔴 Optimized Trading Bot stopped")

print("💡 To shutdown completely, uncomment and run:")
print("optimized_scheduler.shutdown()")
💡 To shutdown completely, uncomment and run:
optimized_scheduler.shutdown()

📝 Zusammenfassung

Position Control erfolgreich implementiert!

Wichtigste Verbesserungen:

  • 🛡️ Maximal 1 Trade gleichzeitig (verhindert Mehrfach-Trades)
  • 🔍 Position-Check vor jedem Trade
  • 📊 Position-Status Monitoring
  • 🔧 Position-Management Funktionen

Hauptfunktionen:

  • execute_trade_v2_with_position_control() - Trading mit Position-Limit
  • check_existing_positions() - Position-Überprüfung
  • get_position_summary() - Position-Status anzeigen
  • close_existing_positions() - Positionen schließen

Wie es funktioniert:

  1. Position-Check vor Signal-Analyse
  2. 🛑 Blockierung wenn bereits Position existiert
  3. 🚀 Trading nur wenn keine Position aktiv
  4. 📊 Verification nach Trade-Ausführung

Problem gelöst: Dein Bot eröffnet jetzt maximal 1 Trade gleichzeitig! 🎉