Files
XauBot/docs/arsitektur-ai/README.md
T
GifariKemalandClaude Opus 4.5 7af9183af3 feat: Smart AI Trading Bot for XAUUSD with ML and SMC
- XGBoost ML model with 37 features for market direction prediction
- Smart Money Concepts (SMC): Order Blocks, FVG, BOS, CHoCH
- HMM market regime detection (trending/ranging/volatile)
- ATR-based stop loss with 1.5 ATR minimum distance
- Broker-level SL protection with fallback
- Time-based exit (max 6 hours per trade)
- Session-aware trading optimized for London/NY overlap
- Auto-retraining based on market conditions
- Telegram notifications and web dashboard
- Backtest results: 63.9% win rate, 2.64 profit factor, 4.83 Sharpe

Backtest period: Jan 2025 - Feb 2026, 654 trades, $4,189 net P/L

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 09:01:35 +07:00

125 lines
4.5 KiB
Markdown

# Arsitektur AI — Smart Trading Bot
> Dokumentasi lengkap semua komponen AI dan sistem pendukung.
---
## Daftar Komponen
### Inti AI & Analisis
| # | Komponen | File Source | Fungsi |
|---|----------|------------|--------|
| 1 | [HMM Regime Detector](01-HMM-Regime-Detector.md) | `src/regime_detector.py` | Deteksi kondisi pasar (radar cuaca) |
| 2 | [XGBoost Signal Predictor](02-XGBoost-Signal-Predictor.md) | `src/ml_model.py` | Prediksi arah harga (navigator AI) |
| 3 | [SMC Analyzer](03-SMC-Analyzer.md) | `src/smc_polars.py` | Analisis struktur pasar institusi (peta jalan) |
| 4 | [Feature Engineering](04-Feature-Engineering.md) | `src/feature_eng.py` | Pengolahan data mentah ke fitur ML (alat ukur) |
### Proteksi & Manajemen Risiko
| # | Komponen | File Source | Fungsi |
|---|----------|------------|--------|
| 5 | [Risk Management](05-Risk-Management.md) | `src/smart_risk_manager.py` | Perlindungan modal (sabuk pengaman) |
| 6 | [Session Filter](06-Session-Filter.md) | `src/session_filter.py` | Pengaturan waktu trading (jadwal kerja) |
| 7 | [Stop Loss (S/L)](07-Stop-Loss.md) | Multi-file | Proteksi 4 lapis dari kerugian |
| 8 | [Take Profit (T/P)](08-Take-Profit.md) | Multi-file | Pengambilan profit cerdas 6 layer |
### Proses Trading
| # | Komponen | File Source | Fungsi |
|---|----------|------------|--------|
| 9 | [Entry Trade](09-Entry-Trade.md) | `main_live.py` | Proses masuk posisi (11 filter) |
| 10 | [Exit Trade](10-Exit-Trade.md) | `main_live.py` | Proses keluar posisi (10 kondisi) |
### Pendukung
| # | Komponen | File Source | Fungsi |
|---|----------|------------|--------|
| 11 | [News Agent](11-News-Agent.md) | `src/news_agent.py` | Monitoring berita ekonomi |
| 12 | [Telegram Notifications](12-Telegram-Notifications.md) | `src/telegram_notifier.py` | Notifikasi real-time ke Telegram |
### Training & Validasi
| # | Komponen | File Source | Fungsi |
|---|----------|------------|--------|
| 13 | [Auto Trainer](13-Auto-Trainer.md) | `src/auto_trainer.py` | Retraining model otomatis (pelatih malam) |
| 14 | [Backtest](14-Backtest.md) | `backtests/backtest_live_sync.py` | Simulasi trading 100% sync dengan live |
| 15 | [Dynamic Confidence](15-Dynamic-Confidence.md) | `src/dynamic_confidence.py` | Penyesuaian threshold otomatis (termometer) |
---
## Pipeline Lengkap
```
Raw OHLCV dari MT5
|
v
[Feature Engineering] -> 40+ fitur numerik (RSI, ATR, MACD, BB, EMA, ...)
|
v
[SMC Analyzer] -> Swing, FVG, OB, BOS, CHoCH, Liquidity
| + Signal (entry, SL ATR-based, TP ATR-capped)
|
+---+---+
| |
v v
[HMM] [XGBoost]
Regime Signal
| |
+---+---+
|
v
[Signal Combination] -> SMC + ML harus setuju
|
v
[News Agent] -> Monitor berita (tidak blocking)
|
v
[Session Filter] -> Cek waktu boleh trading?
|
v
[ENTRY TRADE] -> 11 filter harus PASS:
| Session, Risk Mode, SMC Signal, ML Confirm,
| ML Agree, Quality, Confirmation 2x, Pullback,
| Cooldown, Position Limit, Lot Size
|
v
[Risk Management] -> Hitung lot aman, apply multiplier
|
v
[Execute Order] -> Kirim ke MT5 dengan broker SL & TP
|
v
[Telegram] -> Notifikasi trade open
|
v
[EXIT MONITORING] -> Setiap 1 detik, 10 kondisi exit:
| Smart TP, Early Exit, Golden Hold, ML Reversal,
| Max Loss, Stall, Daily Limit, Weekend, Time-based, Hold
|
v
[Close Position] -> Record result, update risk, notify
```
---
## Ringkasan Peran Setiap Komponen
| Komponen | Pertanyaan yang Dijawab |
|----------|------------------------|
| Feature Engineering | "Data mentah ini berarti apa?" |
| SMC Analyzer | "Dimana institusi besar trading? Entry/SL/TP dimana?" |
| HMM | "Kondisi pasar bagaimana sekarang?" |
| XGBoost | "Harga akan naik atau turun?" |
| Session Filter | "Sekarang waktu yang tepat untuk trading?" |
| News Agent | "Ada berita high-impact yang perlu diperhatikan?" |
| Risk Management | "Berapa besar boleh trading? Sudah aman?" |
| Stop Loss | "Bagaimana melindungi dari kerugian?" |
| Take Profit | "Kapan mengambil profit?" |
| Entry Trade | "Apakah semua syarat terpenuhi untuk masuk?" |
| Exit Trade | "Apakah sudah waktunya keluar?" |
| Telegram | "Apa yang sedang terjadi?" |
| Auto Trainer | "Apakah model AI masih akurat? Perlu dilatih ulang?" |
| Backtest | "Apakah strategi ini profitable di data historis?" |
| Dynamic Confidence | "Seberapa selektif bot harus trading saat ini?" |