This document is for Williams Family Trading Dojo members only.
Every component. Every rule. Every known failure. — Williams Family Trading Dojo
MillionaireSensei is a fully-automated options trading system combining TradingView technical signals, a Google Apps Script processing brain, Firebase for state management, Alpaca for trade execution, and a custom Cloud Run brain-bridge service.
| Component | Technology | Role |
|---|---|---|
| TradingView | Pine Script v6 | Generates CALL/PUT alerts via 12-strategy execution engine (MS_Execution_V8.1) and 40-ticker screener (MS_Screener_V8.1) |
| GAS Brain | Google Apps Script (Code.js @271) | Receives webhook alerts, scores signals, places Alpaca orders, writes to Firestore via brain-bridge |
| Firebase | Firestore + Hosting | State persistence; hosts the dashboard |
| Brain-Bridge | Cloud Run (brainbridge-ctxkltuw3q-wl.a.run.app) | Relay between GAS and Firestore; handles trade lifecycle events |
| HMM Oracle | Cloud Run (hmm-oracle-v3) | GaussianHMM on SPY daily data — NORMAL_VOL / HIGH_VOL regime |
| Alpaca | paper-api.alpaca.markets | Options order execution (paper until Monte Carlo passes) |
| Telegram | Telegram Bot API | Notifications for every trade, signal, system event |
| Jaclau (AI) | claude-sonnet-4-6 | Autonomous AI trader shadowing Johnpaul's strategy |
| Resource | URL / ID |
|---|---|
| Dashboard | https://millionairesensei.com |
| GAS /exec endpoint | https://script.google.com/macros/s/AKfycbzLBZ69pMA2MS-oWHIzTpUhCsGo81eBNzf0KnXyrUYMLaiwk5ouTw26hnBGt9gWx2em_Q/exec |
| Brain-Bridge URL | https://brainbridge-ctxkltuw3q-wl.a.run.app |
| Brain-Bridge Revision (good) | 00025-tud — verified 2026-05-26 |
| HMM Oracle | Cloud Run: hmm-oracle-v3 |
| Alpaca paper account | PA3BA272BSXS — paper-api.alpaca.markets |
| Secret | Millionaire$ensei1968 |
| Current Build | @271 — deployed 2026-05-27 |
The Google Apps Script brain is the central processing unit. It receives TradingView webhooks, scores signals, manages the signal queue, places Alpaca orders, and writes all trade lifecycle events to Firestore via the brain-bridge.
doPost()processSignalQueue() picks up within 1 minutetrade_open event to brain-bridge → written to Firestoretrade_close pushed to brain-bridge → Ledger updated, P&L recorded| Property Key | Purpose |
|---|---|
APPS_SCRIPT_RELAY_SECRET | Primary auth secret: Millionaire$ensei1968 |
ALPACA_API_KEY | Alpaca paper API key |
ALPACA_SECRET_KEY | Alpaca paper secret key |
ALPACA_BASE_URL | https://paper-api.alpaca.markets/v2 (change ONLY after Monte Carlo pass) |
BRAIN_BRIDGE_URL | https://brainbridge-ctxkltuw3q-wl.a.run.app |
TELEGRAM_BOT_TOKEN | Telegram bot token (sensitive — never log) |
MS_APP_VERSION | Base version string (e.g. "4.2"). CONFIG.MS_VERSION getter appends Build @NNN from MS_DEPLOY_NUMBER — Telegram headers show "v4.2 Build @NNN". |
MS_DEPLOY_NUMBER | Forever-incrementing build counter. Current: 271 |
FRED_API_KEY | FRED API key — macro context in morning briefs + VIX fallback |
MIN_SCORE_NORMAL | Minimum signal score in normal volatility (default: 5) |
MIN_SCORE_HIGH_VIX | Minimum signal score when VIX > 25 (default: 7) |
Always use REDEPLOY_GAS_AND_INSTALL.bat — never CLASP_PUSH.bat alone.
CLASP_PUSH only updates the source files. The live /exec endpoint is pinned to a versioned deployment ID. It keeps serving old code until clasp deploy runs.
The bat runs all 4 required steps: (1) clasp push, (2) clasp deploy -i DEPLOY_ID, (3) install_ts_trigger, (4) purge_old_versions.
| What changed | Which bat |
|---|---|
| Code.js (any line) | REDEPLOY_GAS_AND_INSTALL.bat |
| index.html only | DEPLOY_HOSTING_ONLY.bat |
| Both Code.js + index.html | Run BOTH bats sequentially |
CLASP_PUSH.bat alone | ⛔ NEVER for Code.js — use only for non-GAS file syncing |
Before every index.html deploy, run the duplicate-const grep:
grep -n "^ const [A-Z_]" firebase/public/index.html | awk -F: '{print $2}' | sort | uniq -d
Any output = duplicate const declarations = parse-time SyntaxError = login spinner freezes with no visible error.
After every deploy, run the ms-system-test skill. Quick verify for GAS: call get_option_prices — valid JSON with a prices key = live. Raw string "ok" = stale deployment, run the bat again.
| Panel | Data Source | Key Behavior |
|---|---|---|
| Hero Strip | Firestore users/{uid} | P&L pill, portfolio value. INFLATION: raw + $1,000,000 at display layer ONLY. |
| Engine Room | Firestore trades + GAS get_option_prices | Active positions with Live/Close prices. HMM regime badge. Trailing stop protection events. |
| Radar | Brain-bridge signals | Incoming TradingView signals. Off-hours signals appear here too (v4.4 behavior). |
| Leaderboard | Firestore users collection | Johnpaul and Jaclau ranked by portfolio value. |
| Head-to-Head | Firestore | Johnpaul vs Jaclau side-by-side. |
| Ledger / Activity Tape | Firestore trades | Closed trades with entry/exit prices and P&L. Entry price fallback: t.premium. |
Off-hours signals ARE logged to the Radar panel. Telegram notification IS sent. Alpaca order execution IS suppressed. Response does NOT indicate a hard block. The old blocked: true behavior was removed in v4.4.
| Collection / Path | Contents | Writer |
|---|---|---|
users/{uid} | Portfolio value, settings (tradingMode, mirrorJaclau), display totals | GAS via brain-bridge |
users/{uid}/trades/{tradeId} | Full trade lifecycle: all trade_open fields, exitPrice, status, P&L | GAS via brain-bridge |
users/{uid}/settings | tradingMode, mirrorJaclau toggle | Dashboard UI |
system/state | MS_VERSION, last HMM regime, brain-bridge heartbeat | GAS + HMM Oracle |
radar/{signalId} | Incoming signal events | Brain-bridge |
| Action | Must Verify End-to-End |
|---|---|
| Trading Mode switch | Firestore users/{uid}/settings.tradingMode |
| Close button click | Firestore trades/{tradeId}.status = 'closed' AND exitPrice populated AND Alpaca position closed |
| Trailing stop | processPendingTrailingStops_ trigger listed in GAS project triggers |
| Liquidate All | GAS returns JSON {ok: true} — NOT an HTML "Page Not Found" |
Cloud Run service relaying between GAS and Firestore. Current good revision: 00025-tud (verified 2026-05-26). Bad revision: 00015-mn2 — never route traffic back.
X-MS-Secret: Millionaire$ensei1968. Body must contain a type field.| Error | Meaning |
|---|---|
401 Unauthorized | Header name or value is wrong. Confirm X-MS-Secret (not secret in body). |
400 Missing type field | Auth is WORKING — body needs a type field added. |
400 Unknown type: X | Auth is WORKING — use a valid type like get_jaclau_today_summary. |
Cloud Run service (hmm-oracle-v3) running GaussianHMM on SPY daily data. Non-blocking advisory overlay — modifies risk sizing, does NOT gate trades.
| Regime | Meaning | Risk Multiplier |
|---|---|---|
NORMAL_VOL | Low volatility, trending conditions | 1.0 (full position size) |
HIGH_VOL | Elevated volatility, choppy conditions | 0.5 (half position size) |
STALE | HMM Oracle has not run today — expected pre-market | 1.0 (no penalty) |
Cloud Scheduler job: hmm-daily-regime-sync — fires 1:15 PM PT (4:15 PM ET) weekdays.
Force a run: Cloud Console → Cloud Scheduler → hmm-daily-regime-sync → Force Run.
| Field | Value |
|---|---|
| Paper account ID | PA3BA272BSXS |
| Paper API base | https://paper-api.alpaca.markets |
| Live API base (future) | https://api.alpaca.markets — only after Monte Carlo review passes |
| Options WebSocket | wss://stream.data.alpaca.markets/v1beta1/indicative-options |
Ticker + YYMMDD + C/P + 8-digit strike (strike × 1000, zero-padded).
Example: SPY260620C00500000 = SPY CALL, Jun 20 2026, strike $500.00
bp = bid_price, ap = ask_price. NEVER use bid_price or ask_price — they will always be undefined.40-ticker scanner — 40 request.security() calls, at the Pine Script limit. Each ticker is evaluated for CALL/PUT confluence using the same 12-strategy logic as the execution chart.
40-Ticker Watchlist (Build @271): AAPL, ADBE, AFRM, AMD, AMZN, APP, ARM, AVGO, COIN, CRM, CRWD, DKNG, GOOGL, GS, IWM, JPM, LLY, META, MRVL, MSFT, MU, NFLX, NVDA, ORCL, PANW, PLTR, PYPL, QQQ, ROKU, SHOP, SMCI, SMH, SNOW, SOFI, SPCX, SPY, TSLA, UBER, V, XYZ
MS_Screener_V8.1 removed VIX from request.security() to free the 40th slot for SPCX. VIX is now sourced independently by GAS:
getGasVix_() 1. Yahoo Finance %5EVIX — ~15-second refresh (primary) 2. FRED VIXCLS — official EOD (fallback) CacheService: 60-second cache under key 'GAS_VIX_LIVE_'
MS_Execution_V8.1 retains its own CBOE:VIX call (separate 40-call budget; only 3 calls used on single-symbol chart — fine).
MS_Screener_V8.2.pine — 70-ticker v6 dynamic loop using Pine Script v6 array iteration. Reserved for future activation when the 40-ticker limit becomes a constraint.
Pine Script v6 indicator detecting 12 named strategy types on the live single-symbol chart.
| ID | Strategy | Trigger |
|---|---|---|
| S1 | VWAP Reclaim Call / Rejection Put | Fresh VWAP cross + volume surge |
| S2 | Opening Range Breakout Long/Short | ORH/ORL break after 9:30–10:00 ET |
| S3 | Opening Range Retest Long/Short | Retesting sealed ORH/ORL |
| S4 | Pullback Continuation | Trend intact, returned to VWAP, bouncing |
| S5 | Break-and-Retest | Consolidating at prior S/R level |
| S6 | Failed Breakdown/Breakout Reversal | Wick + recovery candle |
| S7 | Liquidity Sweep Reversal | Stop hunt → reversal candle |
| S8 | Relative Strength/Weakness | Ticker outperforms/underperforms SPY by threshold % |
| S9 | Compression Breakout | Bollinger squeeze release + direction |
| S10 | Prior-Day High Reclaim / PDL Rejection | PDH/PDL level interaction |
| S11 | VWAP Extension Mean Reversion | Extreme overextension snap-back |
| S12 | Directional Debit Spread | Default for strong directional alignment |
Autonomous AI trading agent powered by claude-sonnet-4-6. Shadows Johnpaul's strategy using paper trades on Alpaca.
| Setting | Value |
|---|---|
| AI Model | claude-sonnet-4-6 |
| Capital allocation | $1,000 (Firestore users/jaclau/settings.capital) |
| mirrorJaclau toggle | Dashboard Settings drawer — must be ON for autonomous trades |
| Trading mode required | Both (enables paper shadow for Jaclau) |
| Date | Event |
|---|---|
| 2026-05-26 (done) | FIRST Monte Carlo — VERDICT: NOT READY (21 trades, negative EV) |
| Every Friday after close | Recurring Monte Carlo analysis |
| Earliest possible live date | 2026-06-04 — only if Friday May 30 Monte Carlo passes all 5 criteria |
| Metric | Current | Target | Status |
|---|---|---|---|
| Win Rate | 33.3% | ≥ 45% | ⛔ BELOW |
| Avg Win | $+35.00 | ≥ $80 | ⛔ BELOW |
| Avg Loss | $-155.57 | ≤ $80 | ⛔ ABOVE LIMIT |
| Risk/Reward | 0.22:1 | ≥ 1.5:1 | ⛔ INSUFFICIENT |
| Expectancy/trade | -$100 | > $0 | ⛔ NEGATIVE EV |
| Sample size | 21 trades | ≥ 50 | ⚠️ TOO SMALL |
| Fix | Target Impact |
|---|---|
| Let winners run (hold until +25% minimum gain) | Win avg from $35 → $80+ |
| Tighten trailing stop to -15% max loss | Loss avg from $155 → $80 |
| Improve entry timing (wait for bar confirmation) | Win rate from 33% → 45%+ |
| ID | Bug | Root Cause | Watch For |
|---|---|---|---|
| R1 | $1M inflation not displaying | Display calculation missing | +1000000 at display layer in update_user_summary |
| R2 | Activity Tape entry price showing em-dash | Missing fallback field | Fallback to t.premium in Ledger display |
| R3 | P/L not recording on close | Missing ×100 multiplier | P/L formula with options ×100 multiplier |
| R4 | get_option_prices returned raw "ok" | CLASP_PUSH without REDEPLOY | Always REDEPLOY_GAS_AND_INSTALL.bat |
| R5 | Close button not wired | Missing event handler | closeTrade() wired with correct tradeId |
| R6 | Trailing stop not firing | Trigger not installed | install_ts_trigger in REDEPLOY bat |
| R7 | LIQUIDATE ALL returned HTML | Wrong URL construction | URLSearchParams with POST to correct GAS_URL |
| R8 | Brain-bridge serving wrong revision | Traffic not updated | Route 100% to 00025-tud. Never use 00015-mn2. |
| R9 | getCredsFromFirestore_ GET vs POST bug | Wrong HTTP method | Changed to POST |
| R10 | Orphaned checkWsServiceHealth trigger | Old service removed | Trigger deleted |
| R11 | LIQUIDATE ALL sent secret as undefined | ADMIN_GAS_SECRET inside function scope | Must be at module scope (~line 8421) |
| R12 | Login froze (duplicate const) | const ADMIN_GAS_SECRET declared twice | Pre-deploy grep check |
| R13 | Login froze (Write tool truncated index.html) | Write tool on 8000+ line file | NEVER use Write on index.html — use Edit |
| Skill | When to Use | What It Does |
|---|---|---|
ms-gas-deploy | Any Code.js change or GAS deploy | Enforces the 2-step deploy rule |
ms-system-test | After any deploy, pre-market, health checks | Runs all 15 tests, saves dated report |
ms-hmm-oracle | Engine Room OFFLINE, regime stale | Cloud Run navigation, restart procedures |
ms-alpaca-options | Alpaca options orders, WebSocket quotes, OCC symbols | Order types, WebSocket field names (bp NOT bid_price) |
ms-cloud-arch | Firestore HWM, Cloud Run WebSocket, GAS triggers | Firebase patterns, Cloud Run config |
ms-google-signin | Login broken, access denied, whitelist | Firebase Auth config, recovery procedures |
NEVER use CLASP_PUSH alone for Code.js. Always use REDEPLOY_GAS_AND_INSTALL.bat.
NEVER use the Write tool on index.html. Always use Edit for targeted changes.
Run pre-deploy duplicate-const grep before every index.html deploy.
Run ms-system-test after every deploy. Always.
NEVER write portfolio inflation (+$1M) to Firestore or Alpaca. Display layer only.
Verify Trading Mode, Close, Trailing Stop, and Liquidate All END-TO-END in Firestore.
DO NOT switch to live trading until all 5 Monte Carlo criteria pass.
| Situation | Action |
|---|---|
| Login spinner freezes | Run duplicate-const grep on index.html → check file length (not truncated) → redeploy with DEPLOY_HOSTING_ONLY.bat |
get_option_prices returns raw "ok" | Run REDEPLOY_GAS_AND_INSTALL.bat — CLASP_PUSH was run without REDEPLOY |
| Engine Room shows OFFLINE | Load ms-hmm-oracle skill → check Cloud Run → force run Cloud Scheduler hmm-daily-regime-sync |
| LIQUIDATE ALL returns HTML | Check liquidate handler — must POST to GAS_URL with source='liquidate_all' in body |
| Brain-bridge returns 401 | Confirm header is X-MS-Secret (NOT secret in body). Value: Millionaire$ensei1968 |
| Trailing stop not firing | Run install_ts_trigger → check GAS triggers for processPendingTrailingStops_ |