# Auto Confluence

> Composite market regime classifier, multi-timeframe directional bias scorer, and ATR-clustered confluence engine.

Canonical page: [https://docs.kami.trade/studies/auto/](https://docs.kami.trade/studies/auto/)

`auto` orchestrates ten underlying studies in a single deterministic pass, classifies the current market regime, scores directional bias across LTF/HTF structure and VPVR, clusters overlapping price features into ranked confluence zones, and renders a clean ~12-drawing composite overlay.

> **Mutually exclusive with individual studies.** Turning `auto` on hides individual studies so the chart stays readable; toggling any individual study on turns `auto` off.

## Parameters

| Parameter | Default | Range | Type | Role |
| --- | --- | --- | --- | --- |
| `window` | `500` | `60..2000` | integer | Trailing closed candles in `fixed` scope |
| `levels` | `4` | `0..8` | integer | Max S/R bands (`0` disables `sr`) |
| `zones` | `2` | `0..4` | integer | Max S/D zones (`0` disables `zones`) |
| `fvg` | `2` | `0..4` | integer | Max Fair Value Gaps (`0` disables `fvg`) |
| `liquidity` | `2` | `0..4` | integer | Max liquidity pools and sweeps (`<= 2` each) |

## Sub-Studies Executed

`auto` runs `structure` (`maxLabels: 0, maxEvents: 2`), `sr`, `trend` (`max: 1`), `zones`, `range`, `fvg`, `liquidity`, `vpvr`, `sessions` (`showIntraday: 0`), and `htf` (`maxLevels: 2, maxFvg: 0`) — all respecting timeframe-smart defaults (`TF_DEFAULTS`) and closed HTF inputs.

## Deterministic Market Regime

Classified in strict priority order:

| Regime | Condition |
| --- | --- |
| `ranging` | `range.box.status === 'active'` |
| `breakout_up` | `range.box` broke up within the last `15` closed bars |
| `breakout_down` | `range.box` broke down within the last `15` closed bars |
| `trending_up` | External `structure.trend === 'up'` and (`internalTrend === 'up'` or a rising trendline holds) |
| `trending_down` | External `structure.trend === 'down'` and (`internalTrend === 'down'` or a falling trendline holds) |
| `choppy` | All other states |

## Directional Bias Scoring

`biasScore` aggregates four independent signals (`>= +2` → `'bullish'`, `<= -2` → `'bearish'`, else `'neutral'`):

| Signal | Bullish weight | Bearish weight |
| --- | --- | --- |
| External `structure.trend` | `+2.0` | `-2.0` |
| Internal `structure.internalTrend` | `+1.0` | `-1.0` |
| Each HTF timeframe `trend` (`1h`/`4h`/`1d`) | `+1.5` | `-1.5` |
| `vpvr` position (`above_va` / `> poc` vs `below_va` / `< poc`) | `+1.0` | `-1.0` |

## Confluence Clustering (`clusterConfluences`)

Active features across all sub-studies are weighted and clustered whenever they overlap in price or sit within `0.5 * atr[n - 1]` of the cluster mean:

| Feature | Base weight |
| --- | --- |
| HTF Support / Resistance | `1.5` |
| VPVR `POC` | `1.4` |
| Fresh Supply / Demand zone | `1.3` (`0.9` tested/mitigated) |
| Session `PDH` / `PDL` / `PWH` / `PWL` | `1.25` (`1.0` for `DO`/`WO`/`PDM`) |
| Unbroken S/R band | `1.2 + min(majorTouches, 3) * 0.2` |
| Fresh FVG | `1.15` (`0.85` partial/inverted) |
| `EQH` (BSL) / `EQL` (SSL) pool | `1.1` |
| HTF Dealing Range `EQ` | `1.0` |
| VPVR `VAH` / `VAL` | `0.9` |
| LTF Dealing Range `EQ` | `0.85` |

Clusters with at least `2` distinct factor labels are scored by `r2((wSum * (1 + (uniqueFactors - 2) * 0.35)) / (1 + distAtr / 4))`, and the top `4` return in `facts.confluences`.

## Composite Drawing Hygiene

To keep the chart readable (~12 drawings max), `auto` applies three de-cluttering rules:
- Draws the active `range` box **or** `trend` rays (never both simultaneously when ranging).
- Suppresses any `fvg` box that overlaps an already-drawn Supply/Demand `zone`.
- Draws `VPVR POC` as a single accent `level` line and includes up to `2` recent `BOS`/`CHoCH` segments (skipping the dealing-range `EQ` line to avoid edge-tag clutter).

## Activation

- **Studies menu**: `Auto: regime, confluence and key levels` (`Auto`)
- **Slash command**: `/auto`
- **Chat phrases**: `auto`, `analyze`, `analysis`, `mark up`
