# MTF architecture (F6)

## Supported timeframes

Platform MTF uses warehouse/OANDA timeframes: **M5, M15, M30, H1, H4, D**.

Pine **W** (weekly) is **not** available on web. S/R Finder web default HTF is **D** (documented deviation from Pine default `W`).

## Provider

- Interface: `MtfCandleProvider` (`lib/indicators/mtf/types.ts`)
- Client implementation: `createClientMtfCandleProvider(feed)` → `/api/candles` (live) or `/api/warehouse/candles` (warehouse)
- Framework resolver: `resolveMtfCandlesForInstances` (per enabled instance `mtfTimeframes()` metadata)

## Alignment / no lookahead

- **Completed HTF only:** `alignMtfCompletedToChartBars` — HTF bar open `h` is visible at chart time `t` only when `h + duration <= t`.
- **HTF pivots for S/R:** `expandHtfPivotsToChartBars` maps confirmed HTF pivots to chart bars by matching confirmation bar open time (no forward-fill).

## Historical behavior

When instances declare MTF needs, chart sync fetches HTF candles for the visible chart range (+ padding) then passes `mtfCandlesByTimeframe` into `runIndicatorInstances`.

## Live behavior (current)

Live chart uses the same client provider on each indicator sync (no new polling loop). OANDA `/api/candles` returns **completed** bars; forming HTF bars are **not** injected into MTF alignment. Full live forming-HTF parity is **not complete** — documented limitation.

## Missing data

Provider returns `NO_DATA` when fetch fails or series is empty. Indicators requiring MTF (e.g. S/R with `useMtf: true`) return **no outputs** rather than chart-TF substitution.

## Command Center readiness

Command Center is **not migrated**. It requires multi-TF `request.security` inputs beyond S/R HTF pivots. Blocked until:

1. Multiple concurrent MTF series per indicator are declared and resolved.
2. Live forming/completed HTF semantics are validated per input.
3. Indicator-specific alignment rules are ported from Pine.

## S/R Finder `useMtf`

Enabled in engine when MTF **D** (or **H4**) data is supplied. Chart toolbar still defaults `useMtf: false`; users can enable MTF via instance parameters when data feed supports the HTF.
