# Channels

> Parallel price channels projecting an opposite rail and 50% median line from the strongest holding trendline.

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

`channel` builds parallel trend channels by pairing the top rising and falling trendline candidates with their farthest opposite extreme and scoring containment, opposite-rail touches, and channel width.

## Parameters

| Parameter | Default | Range | Type | Timeframe overrides |
| --- | --- | --- | --- | --- |
| `window` | `500` | `60..2000` | integer | — |
| `pivotSpan` | `3` | `2..10` | integer | `4` on `<= 5m`, `2` on `>= 1d` |
| `tolAtr` | `0.25` | `0.05..1.5` | number | — |
| `maxPivots` | `24` | `4..40` | integer | — |
| `minTouches` | `3` | `2..10` | integer | — |

## Algorithm & Nuances

1. **Candidate pool**: Takes up to 3 deduplicated rising trendlines and 3 falling trendlines from `trendScan` (using the same `minTouches = 2` fallback as [`trend`](https://docs.kami.trade/studies/trend/)).
2. **Opposite rail fitting (`channelFit`)**: For each candidate starting at bar `a`, scans `[a, n)` to locate the farthest opposite extreme `far` (highest high above rising support, or lowest low below falling resistance) defining channel vertical width `dist`.
3. **Containment & opposite touches**: Counts bars closing within `[lo - tol, hi + tol]` (`inside`) and opposite-rail touches within `tol` spaced by at least `TOUCH_GAP = 3` bars (`oppTouches`).
4. **Channel scoring**:
   ```
   chScore = cand.score + 0.8 * oppTouches + 1.5 * (inside / max(1, n - a))
             - 0.15 * max(0, widthAtr - 8)
   ```
   Penalizing `widthAtr > 8` prevents overly wide, uninformative channels from beating tight structures. Picks the single highest-scoring channel across both directions (tie-break: newer second anchor `b`, then rising).

## Drawings & Facts

- **Drawings**: `0` or `1` `channel` overlay showing a solid base rail, a dashed parallel rail through `offset`, a faint dashed 50% median line, and a translucent fill, projected to the right edge. Labeled `(Rising|Falling) channel · baseT+oppT touches · widthAtr ATR`.
- **Facts (`ChannelFacts`)**: `base` (anchor line), `offset` (opposite anchor), `width`, `widthAtr`, `closesInside`, `oppositeTouches`, `medianAtEnd`, and `positionInChannel` (all `null` when no qualifying base trendline exists).

## Activation

- **Studies menu**: `Channel`
- **Slash command**: `/channel`
- **Chat phrases**: `channel`, `channels`, `parallel`, `ch`
