Public
Autonomous XAU/USD Signal Bot with Military Chain-of-Command
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Autonomous XAU/USD Signal Bot with Military Chain-of-Command Structure
Supreme Headquarters
├── Supreme Commander (signal-pipeline.ts) — Global orchestration
├── Capital Allocator (risk.ts) — Position sizing
├── Regime Detector (regime.ts) — Market regime classification
└── Catastrophic Override (risk.ts) — Drawdown lockdown
Theater Command Layer (4 Generals)
├── General Technical (10 battalions)
├── General Fundamental (5 battalions)
├── General Sentiment (5 battalions)
└── General Timing (5 battalions)
Special Operations Layer (5 battalions)
├── SMC Order Block, FVG, Risk Parity
├── Regime Adaptive, Volatility Breakout
Connector & Data Layer
├── Data Provider (Twelve Data API + fallback)
├── Telegram Bot API
├── TradingView Webhook Receiver
└── SQLite Database (signals, battalions, regime history)
Real Price Data → Indicator Calculation → Battalion Evaluation
→ Confluence Scoring → Risk Veto Check → Chart SVG Generation
→ Telegram Alert → SQLite Persistence → Dashboard Update
| Theater | Division | Battalions |
|---|---|---|
| Technical | Moving Averages | SMA Golden Cross, EMA Triple, Hull MA |
| Technical | Trend Following | ADX Trend Rider |
| Technical | Breakouts | Bollinger Breakout |
| Technical | Reversals | RSI Divergence |
| Technical | Price Action | Pin Bar |
| Technical | Momentum | MACD, Stochastic |
| Technical | Multi-TF | Multi-TF Confluence |
| Fundamental | Interest Rates | DXY Inverse, Real Yields |
| Fundamental | Macro | Safe Haven, Geopolitical |
| Fundamental | Supply Demand | Central Bank |
| Sentiment | Positioning | COT, Retail Contrarian |
| Sentiment | Market Sentiment | Fear/Greed, News NLP, Social Buzz |
| Timing | Session Trading | London Breakout, NY Momentum |
| Timing | Day Trading | Scalper |
| Timing | Swing Trading | Swing Trader, Weekly Position |
| Special Ops | Hybrid SMC | Order Block, FVG |
| Special Ops | Risk Mgmt | Risk Parity |
| Special Ops | Regime | Regime Adaptive |
| Special Ops | Mathematical | Volatility Breakout |
| Stars | Score | Action |
|---|---|---|
| 5 ★ | 90-100% | Supreme Commander auto-approves |
| 4 ★ | 75-89% | High confidence, standard size |
| 3 ★ | 60-74% | Moderate confidence, reduced size |
| 2 ★ | 40-59% | Low confidence, micro size |
| 1 ★ | <40% | Rejected by Risk Command |
- Level 1 (Battalion): Trade risk > 2% → Veto
- Level 2 (Division): 3 consecutive losses → Stand down 24h
- Level 3 (Theater): Theater drawdown > 5% → Reduce 50%
- Level 4 (Supreme): Total drawdown > 5% → Lockdown / > 10% → Emergency stop
| Endpoint | Description |
|---|---|
/dashboard | Military command center dashboard (React) |
/api/v1/dashboard | Full dashboard data (JSON) |
/api/v1/dashboard/summary | Summary metrics |
/api/v1/dashboard/theaters | Theater status |
/api/v1/dashboard/battalions | Battalion performance |
/api/v1/dashboard/signals | Recent signals |
/api/v1/dashboard/risk | Risk metrics |
/api/v1/dashboard/regime | Market regime |
POST /api/v1/scan | Trigger signal scan |
POST /webhook | TradingView webhook receiver |
POST /telegram | Telegram bot webhook |
/health | Health check |
| Variable | Description | Required |
|---|---|---|
TWELVE_DATA_API_KEY | Twelve Data API key for real XAU/USD data | Recommended |
TELEGRAM_BOT_TOKEN | Telegram bot token for signal alerts | Optional |
TELEGRAM_CHAT_ID | Telegram channel/chat ID | Optional |
👉 Add TWELVE_DATA_API_KEY here: https://www.val.town/x/peterweru/operation-gold-master/environment-variables?key=TWELVE_DATA_API_KEY
👉 Add TELEGRAM_BOT_TOKEN here: https://www.val.town/x/peterweru/operation-gold-master/environment-variables?key=TELEGRAM_BOT_TOKEN
👉 Add TELEGRAM_CHAT_ID here: https://www.val.town/x/peterweru/operation-gold-master/environment-variables?key=TELEGRAM_CHAT_ID
The scan.ts interval runs every hour, executing the full signal pipeline:
- Fetches real XAU/USD candles from Twelve Data API
- Computes 18 technical indicators (SMA, EMA, RSI, ADX, ATR, MACD, Bollinger, Stochastic, OBV, HMA, CCI)
- Evaluates all 30 battalions against real indicator conditions
- Calculates cross-battalion confluence scores
- Applies Risk Command veto checks
- Generates annotated SVG charts
- Sends Telegram alerts
- Persists everything to SQLite
- Runtime: Deno (Val Town)
- Framework: Hono (HTTP API + Dashboard)
- Database: SQLite (Turso/libSQL)
- Data: Twelve Data API (XAU/USD OHLC)
- Alerts: Telegram Bot API
- Charts: SVG (candlestick + annotations)
- Frontend: React 18 (via esm.sh CDN)