# Phase F2 — First TradingBite Pine → TypeScript port

**Status:** Complete (v0.6.0)  
**Rollback:** v0.5.0 @ 8220b44 (Phase F1 framework)

## Selected indicator

**TradingBite Support and Resistance Finder 2.1**

| Field | Value |
|-------|--------|
| Pine file | `../../TradingBite/Support-Resistance-Finder-2.1.pine` (read-only legacy) |
| Pine version | `@version=6` |
| Platform id | `tradingbite.sr-finder-2.1` |
| Selection rationale | Documented first proprietary port in `TradingBite/docs/TRADINGBITE-ROADMAP-A-to-Z.md` (“Pick first Pine port: Support-Resistance Finder 2.1”) |

## Purpose

Major swing pivot pools, merge by ATR distance, break removal, wick touch scoring, and scored selection of support/resistance lines to draw (Pine `barstate.islast` draw block).

## TypeScript layout

- `lib/indicators/tradingbite/sr-finder-2_1/simulate.ts` — bar-by-bar state machine + draw selection
- `lib/indicators/tradingbite/sr-finder-2_1/index.ts` — `IndicatorDefinition` + overlay line outputs
- `lib/indicators/overlay-render.ts` — multi-series overlay sync (F1 contract unchanged)

## Parameters

Pine inputs mapped to typed schemas (integer/number/boolean). Chart UI exposes enable/disable only; defaults match Pine except **`useMtf` default `false`** on web (see limitations).

## Output type

Overlay horizontal lines as constant-price line series (`sr.support.*`, `sr.resistance.*`). Pine boxes/labels/dashboard/alerts are **not** rendered in F2.

## Lookback

`majorLeft + majorRight + atrLen` minimum before ATR and pivots stabilize.

## State / `na`

Persistent pools per Pine `var` arrays; simulation runs only on **completed** candles in the batch (aligned with warehouse; live forming bar may differ — see limitations).

## Known limitations (documented, not hidden)

1. **HTF `request.security`** — not available without multi-timeframe candle input. `useMtf: true` yields **no outputs** until a future phase supplies HTF series.
2. **Dashboard, zones, labels, alerts** — Pine UI not ported; calculation + line draw only.
3. **Realtime / `useLiveExtreme`** — not in this Pine file; pivots confirm after `majorRight` bars on completed bars only.
4. **Live OANDA** may include one incomplete candle; Pine uses `barstate.isconfirmed` — slight divergence possible on the latest bar.

## Golden tests

`tests/fixtures/sr-finder-golden-minimal.ts` — fixed OHLCV + expected pool/draw snapshot; wave fixture for S+R lines. Methodology: lock outputs from `simulateSrFinder` after manual bar trace of the port against Pine 2.1 logic.

## Manual verification

Local `npm run dev` — enable **S/R Finder** on EUR/USD M15 (OANDA Live or Warehouse); green support / red resistance horizontals on last-bar selection.

## Out of scope

Additional Pine ports, panel/marker framework UI, backtest, deploy.
