--- tags: - trading - finance - lstm - attention - xauusd - gold - deep-learning - time-series datasets: - JonusNattapong/xauusd-dataset metrics: - cumulative-return - win-rate - mse library_name: tensorflow license: mit model-index: [] --- # XAUUSD Trading AI Model ## Model Description This is a deep learning model for predicting XAUUSD (Gold vs US Dollar) price movements using LSTM neural networks. The model uses technical indicators to forecast next-day closing prices and is designed for algorithmic trading with risk management. ## Intended Use - **Primary Use**: Predict XAUUSD price movements for trading signals - **Secondary Use**: Research and analysis of gold price patterns - **Out of Scope**: Real-time trading without human oversight, other currency pairs ## Model Architecture - **Type**: Bidirectional LSTM Neural Network with Attention - **Layers**: 2 Bidirectional LSTM layers (100 units each) + Self-Attention + Dense layers - **Input Features**: 26 technical indicators including OHLCV, SMA, EMA, RSI, MACD, Bollinger Bands, ATR, CCI, Williams %R, Stochastic Oscillator, ADX, OBV, Momentum, ROC, Returns, Log Returns - **Sequence Length**: 60 days - **Output**: Predicted next-day return (percentage change) - **Loss Function**: Huber loss for robust regression ## Training Data - **Dataset**: Synthetic XAUUSD data (2000-2024) - **Size**: ~1,600 daily samples - **Features**: 26 technical indicators calculated from OHLCV data - **Preprocessing**: Min-Max scaling, sequence creation - **Target**: Next-day percentage return ## Performance Metrics ### Backtest Results (25 years, 2000-2024, 3 months/year) - **Cumulative Return**: -62.26% - **Total Trades**: 121 - **Win Rate**: 20.66% - **Risk Management**: Returns-based strategy with 0.1% threshold - **MSE on Test Set**: 0.0098 ### Model Versions - **xauusd-trading-model**: Trained on 6 months/year data (44.88% return) - **xauusd-trading-model-3months**: Trained on 3 months/year data (-62.26% return) *Note: 3 months/year provides less training data, resulting in lower performance. Use 6 months version for better results.* ## Limitations - Trained on synthetic data, may not generalize to real market conditions - Past performance does not guarantee future results - Requires proper risk management in live trading - Market conditions can change rapidly - No consideration of macroeconomic factors beyond technical indicators ## Ethical Considerations - This model is for educational and research purposes - Always use proper risk management when trading - Not financial advice - Users should understand the risks of algorithmic trading ## Training Procedure 1. Generate synthetic XAUUSD data with realistic price movements 2. Calculate 24 technical indicators 3. Create sequences of 60 days 4. Train Bidirectional LSTM with early stopping 5. Validate on held-out test set 6. Backtest with risk management rules ## Usage ```python from tensorflow.keras.models import load_model import joblib # Load model and scalers model = load_model('lstm_model.h5') scaler_X = joblib.load('scaler_X.pkl') scaler_y = joblib.load('scaler_y.pkl') # Prepare input data with 24 features # Make predictions predictions = model.predict(sequences) ``` ## Contact For questions or issues, please open an issue on the GitHub repository. ## License MIT License