Reference blueprint
MarketPulse · by Kalilur Rahman

From chart pattern to alert to order — in one blueprint.

A complete, build-ready specification that detects trading-signal patterns — harmonic, moving-average, momentum, breakout & volume — then fans an alert out across web, mobile, email, WhatsApp and Telegram, and on your approval routes the order into a paper or live trading account. Every pattern ships with a formula, a detection algorithm and a copy-paste "Claude task" so an agent can build it, module by module.

The live lab runs the real engine (marketpulse/engine/, 22 passing unit tests) in your browser — generate candles, detect signals, approve an alert, place a paper order. No build step, no backend.

⚠️
Engineering documentation — not financial advice. Automated trading can lose money fast. This blueprint defaults to paper trading with a human approval step; live trading is deliberately gated. You are responsible for regulatory compliance (SEBI / SEC / FINRA / MiFID II, etc.) in your jurisdiction.
6
Pattern families
50+
Detectors specified
16
Detectors coded
22 ✓
Unit tests passing
5
Alert channels
2
Execution modes
01 · The pipeline

Seven layers. One typed contract between each.

A detected pattern flows down a strict pipeline — data to signal to alert to order. Each layer speaks only through the shared Signal / Intent / Order schemas, so you can add a new pattern or a new channel without touching the rest.

1

Market data

Real-time streams + historical OHLCV, normalised to Candle[]. Detectors act on closed bars only — no repainting.

2

Indicator & pattern engine

Pure, deterministic detectors emit a Signal with direction, strength, geometry and evidence. Same code runs the backtester.

3

Strategy & risk gate

Confluence rules + filters, position sizing, and hard risk caps turn a signal into an Intent — or reject it.

4

Alert fan-out

Renders an Alert to web · mobile · email · WhatsApp · Telegram with Approve / Reject buttons. First response wins.

5

Order router / OMS

Idempotent (one clientOrderId = one fill, ever), builds brackets/OCO, drives the order lifecycle.

6

Paper simulator  ·  Live broker

Same interface both ways: fill against the live feed (paper) or route to Alpaca / IBKR / Binance / Kite / Angel One (live).

7

Ledger + audit + feedback

Positions, P&L, reconciliation, append-only audit — then notify the outcome back to the same channels.

02 · The pattern library

Six families. 50+ detectors. One Signal.

Every detector implements one interface and emits the same signal object — so the alert and execution layers never care which pattern fired. Highlighted chips are the ones named in the original brief; the rest extend the same engine.

🦋

Harmonic patterns

9 detectors

Fibonacci-ratio XABCD reversal structures. Buy/sell at the final D point in the Potential Reversal Zone, confirmed by a reversal candle.

ButterflyGartleyABCD BatCrabDeep CrabCypherShark3-Drives
📐

Classical chart patterns

10+ detectors

Geometry from swing pivots. The confirmed break is the signal; the projected height is the target.

Head & ShouldersDouble / Triple Top & BottomTrianglesWedgesFlags & PennantsCup & HandleRectangle / Range
🕯️

Candlestick patterns

15+ detectors

Single/two/three-bar formations — used as confirmation at a level, gated by trend context.

EngulfingHammerShooting StarDojiMorning / Evening StarHarami3 Soldiers / CrowsTweezers
📈

Moving-average signals

7 detectors

Trend direction & pullback entries from SMA/EMA relationships.

Golden CrossEMA reversal / pullback Death CrossPrice × MAMA ribbonVWAP crossSupertrend
🎚️

Momentum oscillators

10 detectors

Speed of price — overbought/oversold reclaims, line crosses and divergences.

RSIMACD StochasticStoch-RSICCIWilliams %RROCAwesome OscMFIDivergence
💥

Volatility · breakout · volume · trend

12+ detectors

Band bounces, squeezes, channel breakouts and volume confirmation + regime filters.

Bollinger Band bounceVolume spike BB / TTM squeezeKeltnerDonchian (Turtle)OBVADX / DMIIchimokuParabolic SAR
03 · Signal delivery

One alert. Five channels. First tap wins.

The same Alert object drives every channel. Approve on whichever you see first — the response is idempotent across all of them, so an order can never be placed twice.

🌐

Web app

WebSocket + Web Push; live alerts inbox with Approve / Reject.

📱

Mobile push

FCM / APNs with notification action buttons that deep-link in.

✉️

Email

HTML with an inline chart; buttons are signed, single-use magic links.

💬

WhatsApp

Meta Cloud API template buttons or Twilio; signed inbound webhook.

✈️

Telegram

Inline-keyboard buttons + slash commands: /positions /pause /kill.

🔁

Two-way control

Operate the whole system from chat — positions, pause/resume, mode, kill switch.

🟢 BULLISH · Gartley · AAPL · 1h
Entry 184.20 (limit)
Stop 181.90   Target 188.60 / 191.30
R:R 1.9   Risk $230 (0.9% of equity)
Why D at 0.786 of XA; RSI reclaimed 30
Mode PAPER   Expires 15m
✅ Approve❌ Reject😴 Snooze📈 Chart

Every actionable button carries an HMAC token bound to the alert, action and user. Inbound webhooks are signature-verified. Unapproved alerts auto-expire.

04 · Order execution

Paper first. Live only when you mean it.

Paper and live share one Broker interface — so paper mode is the integration test for the entire pipeline, and going live changes a config flag, not the strategy code.

🧪 Paper simulator

  • Ships first. Fills against the same live feed the engine uses.
  • Realistic slippage + commission models; market / limit / stop logic.
  • Virtual account, positions and P&L — emits the same OrderUpdate a real venue does.
  • The whole pipeline runs end-to-end here before any key is touched.

🏦 Live broker adapters

  • Alpaca — US equities/crypto, native brackets, built-in paper endpoint (first target).
  • Interactive Brokers · Binance · Zerodha Kite · Angel One — same interface, venue-correct signing.
  • Every order carries a deterministic clientOrderIdidempotent, no double-fills.
  • Bracket / OCO protection, partial-fill handling, startup reconciliation.
05 · Risk & safety

Guardrails, not an afterthought.

The risk gate sits between signals and orders and is the most important code in the system. These defaults are baked into every module.

🛡️ Built-in defaults

  • Paper by default — live needs an env flag and a signed per-account ack.
  • Human-in-the-loop — alerts ask before acting; auto-execute is opt-in & capped.
  • Idempotent orders — a retried webhook or double tap can't double-fill.
  • Everything audited — signal → alert → decision → order → fill, append-only.

⚑ Hard limits & circuit breakers

  • Position sizing from risk-per-trade (e.g. ≤1% equity), never a gut quantity.
  • Daily loss stop, max open risk, max positions, leverage & exposure caps.
  • Global kill switch — one flag blocks all new orders; trippable from any channel.
  • Secrets in a vault, never the repo; every webhook signature-verified.
06 · Build roadmap

Twelve milestones, sequenced for Claude.

Each milestone is a paste-ready "Claude task" with acceptance criteria, ordered so nothing depends on code that doesn't exist yet. Paper trading works end-to-end at milestone 7.

0

Skeleton, types & event bus

Shared schemas + interfaces + Postgres with the idempotency index.

1

Market-data ingest

Historical backfill + real-time stream → Candle[].

needs M0
2

Indicator library

Every formula, incremental & unit-tested, in one IndicatorBook.

needs M0
3

Indicator detectors

MA · oscillators · volatility · volume · trend.

needs M2
4

Price-structure detectors

Harmonic · chart · candlestick.

needs M2
5

Backtester

Same detector code, historical feed — strategies become measurable.

needs M1–4
6

Strategy · risk · sizing · kill switch

Confluence rules turn signals into risk-checked intents.

needs M3–4
7

Router + paper simulator + ledger ⭐

Paper trading works end-to-end across the whole pipeline.

needs M6
8

Web / mobile / email alerts

Rendered alerts + idempotent approve → order.

needs M6
9

Telegram + WhatsApp bots

Chat-driven approve → order + control commands.

needs M7–8
10

Live broker adapter (Alpaca)

Live-shaped execution against paper endpoint, then gated live.

needs M7
11

Promotion gates, audit & hardening

Paper→live gates, observability, secret hygiene, circuit breakers.

needs all
07 · All documents

The full specification set.