Noise profiles, session boundaries, and structural swing spans vary dramatically between a 1m scalp chart and a 1d swing chart. Kami adapts study parameters, VWAP resets, and higher-timeframe projections automatically based on the active candle interval.
Supported Intervals
| Interval | Duration (ms) | Parameter tier | Auto VWAP anchor |
HTF targets (HTF_MAP) |
|---|---|---|---|---|
1m |
60,000 |
Low (<= 5m) |
Daily UTC (00:00) |
1h, 1d |
5m |
300,000 |
Low (<= 5m) |
Daily UTC (00:00) |
1h, 1d |
15m |
900,000 |
Baseline | Daily UTC (00:00) |
4h, 1d |
1h |
3,600,000 |
Baseline | Daily UTC (00:00) |
4h, 1d |
4h |
14,400,000 |
Baseline | Weekly UTC (Mon 00:00) |
1d |
1d |
86,400,000 |
High (>= 1d) |
Monthly UTC (1st 00:00) |
None ([]) |
Timeframe-Smart Parameter Defaults
When you omit a parameter, resolveParams() checks TF_DEFAULTS for the chart’s interval before falling back to the base default. Explicit user or agent parameters always win (given[k] ?? tfDefault[k] ?? baseDefault).
| Tier | Condition | Overridden parameters | Base default |
|---|---|---|---|
| Low | intervalMs <= 300,000 (1m, 5m) |
pivotSpan: 4 on sr, trend, channel, structure, liquidity, divergence |
3 |
| Low | intervalMs <= 300,000 (1m, 5m) |
fvg.minGapAtr: 0.45 |
0.3 |
| Low | intervalMs <= 300,000 (1m, 5m) |
zones.impulseAtr: 2.5 |
2.0 |
| Baseline | 15m, 1h, 4h |
None | Base defaults |
| High | intervalMs >= 86,400,000 (1d) |
pivotSpan: 2 on sr, trend, channel, structure, liquidity, divergence |
3 |
| High | intervalMs >= 86,400,000 (1d) |
range.minBars: 8 |
12 |
Why these shifts matter:
- On
1m/5mcharts, tighterpivotSpan: 4filters micro-wick noise, while higherfvg.minGapAtrandzones.impulseAtrreject tiny spread gaps and weak 1-minute candles. - On
1dcharts,pivotSpan: 2catches macro swings without requiring 7-day clusters, andrange.minBars: 8detects 1–2 week consolidations promptly.
Automatic VWAP Session Anchoring
The rolling VWAP indicator inspects candle spacing (dt = t[1] - t[0]) via inferVwapAnchor():
<= 1h(1m,5m,15m,1h): Resets daily at00:00 UTC(Math.floor(ms / 86_400_000)).4h: Resets weekly at Monday00:00 UTC(Math.floor((ms + 3 * 86_400_000) / (7 * 86_400_000))).1d: Resets monthly on the 1st at00:00 UTC(year * 12 + month).
On higher timeframes, resetting VWAP every 24 hours would collapse to a single candle’s typical price (H+L+C)/3 with zero variance. Stepping automatically to Weekly on 4h and Monthly on 1d keeps standard-deviation bands meaningful across every timeframe.
Uniform Multi-Timeframe (HTF) Pipeline
Three studies consume higher-timeframe context (HTF_STUDIES): sessions, htf, and auto. Rather than adding custom per-venue endpoints, Kami uses a uniform hybrid pipeline across every venue:
- Lazy demand: HTF candles are only fetched when an HTF study is active on the chart or requested by Kami AI.
- Local coverage check first: Before hitting the network,
countCompleteBuckets()checks inO(n)zero-allocation time whether the active chart already spans at least60complete HTF buckets. - Background fetch & cache: If local coverage is short,
requestHtf()fires a non-interrupting background load through the standard chart loader (reusing IndexedDB cache and throttling duplicate requests up tomin(intervalMs, 5 min)). Results live in a16-entry LRU cache (market.getHtf). - Automatic boundary rollover: Once a cached HTF bucket rolls over (
now - 5scrosses the next HTF bar boundary, with a 5-second settlement grace period), Kami refreshes the HTF series automatically. - Local aggregation fallback: While background HTF history is loading (or offline),
aggregateSeries()builds complete HTF OHLCV buckets directly from the active chart’s closed candles, dropping any incomplete trailing bucket. - Zero-lookahead clamp:
closedHtf()trims any HTF bar whose close timestamp exceedsMath.min(input.now, windowEnd). When you pan backward inViewscope,htfandsessionsstrictly reflect what was knowable at the right edge of your historical window.