ta.kc
Draw channels around an average at multiples of the average true range.
ta.kc(source, length, mult, bars, useTrueRange)Keltner Channels: [ema(source, length), basis + mult*atr(length), basis - mult*atr(length)], the atr read from bars. With useTrueRange=false the width uses the average of high minus low instead of the true range.
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. |
useTrueRange | Constant | bool | - | true | - | true: the channel width is the average true range, which counts gaps between bars. false: it is the average of high minus low, smoothed the same way (an option, written useTrueRange=false). |
Outputs
| Name | Type | Unit |
|---|---|---|
middle | number | - |
upper | number | - |
lower | number | - |
The outputs come back in this order: [middle, upper, lower] = ta.kc(…).
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.
Example
[basis, upper, lower] = ta.kc(close, 20, 2)[basis, upper, lower] = ta.kc(close, 20, 2)
plot(upper, "Upper")
plot(lower, "Lower")