# ADR-004: Indicator engine (in-process, pure functions)

**Status:** Accepted (Phase F1)  
**Date:** 2026-10-02

## Context

Phase F1 needs a foundation for TradingBite indicators without Pine-in-browser, without backtesting, and without coupling to OANDA vs warehouse storage.

## Decision

- **In-process TypeScript** indicator definitions with a shared `IndicatorDefinition` interface.
- **Registry + `runIndicator()`** as the only calculation entry point for the app.
- **Pure `calculate()`** over `IndicatorCandle[]` (chart-normalized OHLC).
- **Structured outputs** (line / marker) consumed by the chart layer — not SQL, not provider APIs.
- **Reference SMA** as the sole built-in indicator for F1 proof.

## Alternatives considered

| Option | Why not now |
|--------|-------------|
| Web Workers | No demonstrated CPU bottleneck |
| Redis / job queue | Violates $0 / no extra infra |
| Pine runtime in browser | Explicitly out of roadmap for default path |

## Consequences

- Future Pine → TS ports add files + registry entries; engine stays stable.
- Panel indicators will need a second chart pane or LC sub-chart — contract is ready, UI is not.
