Prediksi Harga XAU/USD Menggunakan Algoritma XGBoost dengan Indikator Teknikal RSI, MACD, dan SMA
Abstract
This study addresses the high volatility and non-linearity of XAU/USD price movements, which hinder accurate prediction in financial markets. An experimental quantitative approach was employed, comparing the XGBoost algorithm as the primary model against Random Forest. Daily historical XAU/USD data from 2021 to 2025 (2,556 data points) were collected from Investing.com, processed using forward fill and Interquartile Range-based outlier handling, and augmented with technical indicators (RSI, MACD, and 20- and 50-period SMAs). Data were partitioned using a time-based split (80:20) without randomization to prevent data leakage, with hyperparameter optimization performed via Grid Search and TimeSeriesSplit cross-validation. A one-step-ahead regression forecasting model was developed and integrated with a dynamic risk management strategy (signal threshold: 0.25%; Stop Loss: 0.40%; Take Profit: 0.80%; minimum Risk-to-Reward ratio: 1.8:1); the model was then exported to ONNX format for implementation as an MQL5-based Expert Advisor in MetaTrader 5. Results show XGBoost achieving an MAE of $34.2141, RMSE of $47.3175, and MAPE of 0.9651%; while competitive with Random Forest, it outperformed the latter in mitigating extreme errors. Trading simulations yielded a profit of +$1,549.99—four times the baseline achieved without risk management. A real-world backtest in MetaTrader 5 recorded a Net Profit of +$41,144.11, a Profit Factor of 1.28, and a Win Rate of 39.53%. The integration of XGBoost, technical indicators, and risk management proved effective in creating an accurate and profitable algorithmic trading system.