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.

🪖 OPERATION GOLD MASTER

Autonomous XAU/USD Signal Bot with Military Chain-of-Command Structure

Architecture

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)

Signal Pipeline Flow

Real Price Data → Indicator Calculation → Battalion Evaluation
→ Confluence Scoring → Risk Veto Check → Chart SVG Generation
→ Telegram Alert → SQLite Persistence → Dashboard Update

30 Active Battalions

TheaterDivisionBattalions
TechnicalMoving AveragesSMA Golden Cross, EMA Triple, Hull MA
TechnicalTrend FollowingADX Trend Rider
TechnicalBreakoutsBollinger Breakout
TechnicalReversalsRSI Divergence
TechnicalPrice ActionPin Bar
TechnicalMomentumMACD, Stochastic
TechnicalMulti-TFMulti-TF Confluence
FundamentalInterest RatesDXY Inverse, Real Yields
FundamentalMacroSafe Haven, Geopolitical
FundamentalSupply DemandCentral Bank
SentimentPositioningCOT, Retail Contrarian
SentimentMarket SentimentFear/Greed, News NLP, Social Buzz
TimingSession TradingLondon Breakout, NY Momentum
TimingDay TradingScalper
TimingSwing TradingSwing Trader, Weekly Position
Special OpsHybrid SMCOrder Block, FVG
Special OpsRisk MgmtRisk Parity
Special OpsRegimeRegime Adaptive
Special OpsMathematicalVolatility Breakout

Confluence Scoring

StarsScoreAction
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

Risk Management

  • 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

Live Endpoints

EndpointDescription
/dashboardMilitary command center dashboard (React)
/api/v1/dashboardFull dashboard data (JSON)
/api/v1/dashboard/summarySummary metrics
/api/v1/dashboard/theatersTheater status
/api/v1/dashboard/battalionsBattalion performance
/api/v1/dashboard/signalsRecent signals
/api/v1/dashboard/riskRisk metrics
/api/v1/dashboard/regimeMarket regime
POST /api/v1/scanTrigger signal scan
POST /webhookTradingView webhook receiver
POST /telegramTelegram bot webhook
/healthHealth check

Environment Variables

VariableDescriptionRequired
TWELVE_DATA_API_KEYTwelve Data API key for real XAU/USD dataRecommended
TELEGRAM_BOT_TOKENTelegram bot token for signal alertsOptional
TELEGRAM_CHAT_IDTelegram channel/chat IDOptional

👉 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

Automated Scanning

The scan.ts interval runs every hour, executing the full signal pipeline:

  1. Fetches real XAU/USD candles from Twelve Data API
  2. Computes 18 technical indicators (SMA, EMA, RSI, ADX, ATR, MACD, Bollinger, Stochastic, OBV, HMA, CCI)
  3. Evaluates all 30 battalions against real indicator conditions
  4. Calculates cross-battalion confluence scores
  5. Applies Risk Command veto checks
  6. Generates annotated SVG charts
  7. Sends Telegram alerts
  8. Persists everything to SQLite

Tech Stack

  • 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)