2026-02-09 16:24:05.125 | INFO  | src.mt5_connector:connect:177 - Connected to MT5: FinexBisnisSolusi-Demo (Account: 61045904) 2026-02-09 16:24:05.837 | DEBUG  | src.mt5_connector:get_market_data:449 - Fetched 50000 bars for XAUUSD M15 2026-02-09 16:24:06.039 | DEBUG  | src.mt5_connector:get_market_data:449 - Fetched 2000 bars for XAUUSD H1 2026-02-09 16:24:06.045 | DEBUG  | src.feature_eng:calculate_rsi:130 - RSI calculated (period=14) 2026-02-09 16:24:06.049 | DEBUG  | src.feature_eng:calculate_atr:185 - ATR calculated (period=14) 2026-02-09 16:24:06.051 | DEBUG  | src.feature_eng:calculate_macd:243 - MACD calculated (12/26/9) 2026-02-09 16:24:06.054 | DEBUG  | src.feature_eng:calculate_bollinger_bands:301 - Bollinger Bands calculated (period=20, std=2.0) 2026-02-09 16:24:06.056 | DEBUG  | src.feature_eng:calculate_ema_crossover:357 - EMA crossover calculated (9/21) 2026-02-09 16:24:06.058 | DEBUG  | src.feature_eng:calculate_volume_features:403 - Volume features calculated (period=20) 2026-02-09 16:24:06.068 | DEBUG  | src.feature_eng:calculate_ml_features:518 - ML features calculated 2026-02-09 16:24:06.072 | DEBUG  | src.smc_polars:calculate_swing_points:401 - Swing points: 3062 highs, 3079 lows 2026-02-09 16:24:06.074 | DEBUG  | src.smc_polars:calculate_fvg:312 - FVG calculation complete. Bullish: 5696, Bearish: 4720 2026-02-09 16:24:06.100 | DEBUG  | src.smc_polars:calculate_order_blocks:511 - Order Blocks: 2201 bullish, 2164 bearish 2026-02-09 16:24:06.237 | DEBUG  | src.smc_polars:calculate_bos_choch:599 - BOS: 702 bullish, 458 bearish 2026-02-09 16:24:06.238 | DEBUG  | src.smc_polars:calculate_bos_choch:600 - CHoCH: 616 bullish, 617 bearish 2026-02-09 16:24:06.239 | DEBUG  | src.feature_eng:calculate_rsi:130 - RSI calculated (period=14) 2026-02-09 16:24:06.241 | DEBUG  | src.feature_eng:calculate_atr:185 - ATR calculated (period=14) 2026-02-09 16:24:06.242 | DEBUG  | src.feature_eng:calculate_macd:243 - MACD calculated (12/26/9) 2026-02-09 16:24:06.242 | DEBUG  | src.feature_eng:calculate_bollinger_bands:301 - Bollinger Bands calculated (period=20, std=2.0) 2026-02-09 16:24:06.244 | DEBUG  | src.feature_eng:calculate_ema_crossover:357 - EMA crossover calculated (9/21) 2026-02-09 16:24:06.244 | DEBUG  | src.feature_eng:calculate_volume_features:403 - Volume features calculated (period=20) 2026-02-09 16:24:06.246 | DEBUG  | src.smc_polars:calculate_swing_points:401 - Swing points: 130 highs, 130 lows 2026-02-09 16:24:06.247 | DEBUG  | src.smc_polars:calculate_fvg:312 - FVG calculation complete. Bullish: 256, Bearish: 155 2026-02-09 16:24:06.249 | DEBUG  | src.smc_polars:calculate_order_blocks:511 - Order Blocks: 90 bullish, 82 bearish 2026-02-09 16:24:06.256 | DEBUG  | src.smc_polars:calculate_bos_choch:599 - BOS: 39 bullish, 20 bearish 2026-02-09 16:24:06.256 | DEBUG  | src.smc_polars:calculate_bos_choch:600 - CHoCH: 19 bullish, 19 bearish [I 2026-02-09 16:24:06,480] A new study created in memory with name: xgboost_opt ================================================================================ ML MODEL V3 TRAINING PIPELINE Bismillah - Building Exceptional Model ================================================================================ Fetching 50,000 bars of M15 data... Symbol: XAUUSD Timeframe: M15 Fetched 50,000 bars Date range: 2023-12-27 09:15:00 to 2026-02-09 11:15:00 Fetching 2,000 bars of H1 data... Fetched 2,000 H1 bars Engineering features... M15 technical indicators... SMC structure features... H1 higher timeframe features... Total features: 70 Columns with nulls: 45 rsi, atr, atr_percent, bb_middle, bb_upper, bb_lower, bb_width, bb_percent_b, volume_sma, volume_ratio Filling nulls with forward fill... Labeling data with Triple Barrier Method (BINARY)... Starting Triple Barrier Labeling (BINARY: BUY vs SELL)... Profit target: 0.5 ATR Stop loss: 0.5 ATR Max holding: 20 bars Target Distribution (BINARY): BUY: 27558 (55.14%) SELL: 22422 (44.86%) Unlabeled: 20 (last 20 bars) Quality Metrics: Profit barriers hit: 0 ( 0.00%) Avg bars to profit: 0.0 Avg return (ATR): 0.000 Splitting train/test (stratified, BINARY)... Train: 39,985 samples Test: 9,995 samples Train distribution: BUY=55.1%, SELL=44.9% Test distribution: BUY=55.1%, SELL=44.9% Balancing TRAINING set only (BINARY)... Balancing Classes (BINARY)... Target distribution: BUY=50%, SELL=50% Before: BUY=22047, SELL=17938 After: BUY=17938, SELL=17938 Total samples: 35876 Selected 69 features Sample features: spread, rsi, atr, atr_percent, macd, macd_signal, macd_histogram, bb_middle, bb_upper, bb_lower... Training XGBoost model (BINARY: BUY vs SELL)... Training classes: [0 1] (expected: [0, 1]) Class weights: SELL=1.00, BUY=1.00 Class distribution: SELL=17938 (50.0%), BUY=17938 (50.0%) Running Optuna hyperparameter optimization... 0%| | 0/30 [00:00 trainer.run_full_pipeline() ~~~~~~~~~~~~~~~~~~~~~~~~~^^ File "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI\backtests\ml_v3\train_ml_v3.py", line 572, in run_full_pipeline model = self.train_xgboost(df_train, df_test, feature_cols, optimize_hyperparams=True) File "C:\Users\Administrator\Videos\Smart Automatic Trading BOT + AI\backtests\ml_v3\train_ml_v3.py", line 452, in train_xgboost 'HOLD': int(n_hold), ^^^^^^ NameError: name 'n_hold' is not defined [I 2026-02-09 16:25:17,875] Trial 20 finished with value: 0.5407703851925963 and parameters: {'max_depth': 4, 'learning_rate': 0.014602899345165808, 'n_estimators': 400, 'min_child_weight': 5, 'gamma': 0.22949537460546224, 'subsample': 0.8977153005120271, 'colsample_bytree': 0.8526894924834064, 'reg_alpha': 0.628190744198449, 'reg_lambda': 1.53668178079443}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:19,930] Trial 21 finished with value: 0.551975987993997 and parameters: {'max_depth': 5, 'learning_rate': 0.013728166115300219, 'n_estimators': 100, 'min_child_weight': 7, 'gamma': 0.11674688466703503, 'subsample': 0.8832925720775808, 'colsample_bytree': 0.9406844670218427, 'reg_alpha': 0.859259049911406, 'reg_lambda': 1.0931239193055575}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:22,458] Trial 22 finished with value: 0.5410705352676338 and parameters: {'max_depth': 4, 'learning_rate': 0.030116964126754433, 'n_estimators': 150, 'min_child_weight': 5, 'gamma': 0.20151763838400225, 'subsample': 0.9601353036723839, 'colsample_bytree': 0.9203115337802729, 'reg_alpha': 0.9009410872872456, 'reg_lambda': 0.7750094664399738}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:25,302] Trial 23 finished with value: 0.5492746373186593 and parameters: {'max_depth': 6, 'learning_rate': 0.01339294753324474, 'n_estimators': 100, 'min_child_weight': 3, 'gamma': 0.058259431813236735, 'subsample': 0.9512782574506404, 'colsample_bytree': 0.8759459562515856, 'reg_alpha': 0.7031375771873505, 'reg_lambda': 1.263152604175222}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:27,704] Trial 24 finished with value: 0.5555777888944472 and parameters: {'max_depth': 4, 'learning_rate': 0.02105657731036031, 'n_estimators': 150, 'min_child_weight': 4, 'gamma': 0.4953855001205515, 'subsample': 0.8794522860880686, 'colsample_bytree': 0.945711518848662, 'reg_alpha': 0.8974368290673568, 'reg_lambda': 0.9717851516463702}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:30,612] Trial 25 finished with value: 0.5318659329664832 and parameters: {'max_depth': 4, 'learning_rate': 0.023909784532721495, 'n_estimators': 200, 'min_child_weight': 5, 'gamma': 0.3487960313893796, 'subsample': 0.8857792998249797, 'colsample_bytree': 0.9627521238345718, 'reg_alpha': 0.7947742718055276, 'reg_lambda': 0.8841258055343483}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:33,337] Trial 26 finished with value: 0.5375687843921961 and parameters: {'max_depth': 3, 'learning_rate': 0.03823062379608325, 'n_estimators': 250, 'min_child_weight': 2, 'gamma': 0.46724925592993116, 'subsample': 0.9580996491890573, 'colsample_bytree': 0.8592515568859691, 'reg_alpha': 0.4756767995624783, 'reg_lambda': 0.32662058181207376}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:36,105] Trial 27 finished with value: 0.5518759379689845 and parameters: {'max_depth': 4, 'learning_rate': 0.021818801893925297, 'n_estimators': 150, 'min_child_weight': 7, 'gamma': 0.4827661778417175, 'subsample': 0.8062229944490487, 'colsample_bytree': 0.9621940611258075, 'reg_alpha': 0.8582606561434041, 'reg_lambda': 0.696827833427667}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:40,956] Trial 28 finished with value: 0.5410705352676338 and parameters: {'max_depth': 4, 'learning_rate': 0.01614008329614252, 'n_estimators': 350, 'min_child_weight': 4, 'gamma': 0.0057764730397426856, 'subsample': 0.8892087472397933, 'colsample_bytree': 0.9046109533134686, 'reg_alpha': 0.689648802250914, 'reg_lambda': 1.0145315071864167}. Best is trial 15 with value: 0.5656828414207103. [I 2026-02-09 16:25:51,427] Trial 29 finished with value: 0.5335667833916958 and parameters: {'max_depth': 6, 'learning_rate': 0.03679715841809866, 'n_estimators': 500, 'min_child_weight': 2, 'gamma': 0.36516619625923186, 'subsample': 0.8096607847890015, 'colsample_bytree': 0.9943362428363094, 'reg_alpha': 0.5337652863049553, 'reg_lambda': 1.440253120968756}. Best is trial 15 with value: 0.5656828414207103. Best trial: 15 Best accuracy: 0.5657 Training final model with params: {'max_depth': 4, 'learning_rate': 0.016472304207886358, 'n_estimators': 100, 'min_child_weight': 5, 'gamma': 0.10362444947456231, 'subsample': 0.9138454720520033, 'colsample_bytree': 0.9385941841429721, 'reg_alpha': 0.8646735308549598, 'reg_lambda': 1.2192135814418799} Model Performance (BINARY): Train Accuracy: 0.5775 Test Accuracy: 0.5643 Test Set Classification Report (BINARY): precision recall f1-score support SELL 0.512 0.610 0.557 4484 BUY 0.624 0.527 0.572 5511 accuracy 0.564 9995 macro avg 0.568 0.569 0.564 9995 weighted avg 0.574 0.564 0.565 9995 Confusion Matrix: Predicted SELL BUY SELL 2734 1750 BUY 2605 2906 Training failed: name 'n_hold' is not defined