ta.kcw
Measure the width of the Keltner channel relative to its average, to spot compression.
ta.kcw(source, length, mult, bars)Keltner Channel width: (upper - lower) / basis = 2 * mult * ta.atr(length) / ta.ema(source, length). It uses the same true-range, Wilder-smoothed spread as ta.kc, so the two agree by construction. The bars come from bars. A fraction, not a percentage.
Parameters
A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.
| Name | Kind | Type | Unit | Default | Range | Description |
|---|---|---|---|---|---|---|
source | Series | number | - | - | - | The series to read. |
length | Constant | number | - | 20 | 1 to 10000 | Window in observed bars. |
mult | Constant | number | - | 2 | 0.001 to 50 | Multiples of the average true range from the basis. |
bars | Constant | bars | bars | na | - | Which bars to read: a declared series, or na for the chart's own. |
Output
| Name | Type | Unit |
|---|---|---|
value | number | - |
Warm-up and missing values
- Warm-up
lengthbars. Names in the warm-up are this operator’s parameters.- Missing values
- na until both the exponential average that forms the basis and the average true range have warmed up over
lengthbars. na when the basis is zero.
Example
ta.kcw(close, 20, 2)plot(ta.kcw(close, 20, 2), "Channel width 20")