Public
Gold protection bot: SL reversal + live trading chat
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.

🛡️ Gold Protection Bot

A gold trading protection bot built on Val Town that detects early stop loss reversals, provides a live trading demo chat, and minimizes losses through deep multi-layer analysis.

⚠️ For educational and research purposes only. Gold trading carries significant financial risk.

Features

  • Stop Loss Reversal Detection — Monitors 7 reversal signal types: SL approach, RSI/MACD divergence, market structure breaks, liquidity sweeps, candlestick reversal patterns, momentum shifts, and EMA trend flips
  • Live Trading Chat — Interactive chat assistant that analyzes live market data and gives contextual trade recommendations (auto or manual mode)
  • Paper Trading Demo — Open/close simulated trades with live P&L tracking, win/loss stats, and automatic SL/TP monitoring
  • Source Bot Integration — Pulls recent signals from the Weru Gold Bot to use as context for protection analysis
  • Telegram Alerts — Protection warnings, trade signals, and auto-trade notifications sent to your phone
  • Auto-Trade Mode — Automatically opens trades on strong signals and closes them when protection level hits DANGER/CRITICAL

Getting Started

  1. Settings → paste your Twelve Data API key (free tier: 800 calls/day)
  2. Dashboard → click "Run Protection Check" to start analysis
  3. Live Chat → type "scan", "price", "buy", or "risk" for instant analysis
  4. Demo Trade → open paper trades with SL/TP and track P&L
  5. Telegram (optional) → add bot token + chat ID for push alerts
  6. Dashboard → "Start Auto-Check" for 24/7 monitoring (every 15 min)

Protection Levels

LevelScoreAction
✅ SAFE0-24Hold position
⚠️ CAUTION25-59Tighten stop loss
🛑 DANGER60-84Close position now
🚨 CRITICAL85-100Consider reversing

Architecture

fetch → /api/protect → pipeline → protection engine → persist → notify
                                    ↓
                              analysis engine (hybrid)
                                    ↓
                              auto-trade (if enabled)

File Map

PathPurpose
main.tsHono HTTP API + serves dashboard
cron/autocheck.tsScheduled auto-protection check (every 15 min)
src/lib/protection.tsStop loss reversal detection engine
src/lib/chat.tsAI-style trading chat assistant
src/lib/pipeline.tsFetch → protect → persist → notify → auto-trade
src/lib/analysis.tsHybrid analysis engine (from Weru bot)
src/lib/indicators.tsEMA/RSI/MACD/ATR/swing math
src/lib/patterns.tsCandlestick pattern detection
src/lib/market.tsTwelve Data fetcher
src/lib/telegram.tsTelegram notifier
src/lib/db.tsSQLite schema + helpers (6 tables)
src/frontend/*React dashboard (6 tabs)

Notes

  • Reuses the Weru Gold Bot's analysis engine for signal generation
  • Source bot URL defaults to the Weru bot endpoint (configurable in Settings)
  • Free Val Town tier enforces 15-minute minimum cron interval