kc_upper
Keltner Channels Upper Band
kc_upper(source, length, mult, matype="ema", atr_length=..., atr_matype="wilder", bandstyle="atr")
Parameters
| Name | Type | Description |
|---|---|---|
source |
field | Price field for middle line calculation (typically close) |
length |
int | Period for middle line MA calculation |
mult |
float | Multiplier for band width |
matype |
str, optional | MA type for middle line |
atr_length |
int, optional | Period for volatility calculation (ATR/range) |
atr_matype |
str, optional | MA type for ATR smoothing |
bandstyle |
str, optional | Volatility measurement method |
Formula
```
middle = MA(source, length, matype)
if bandstyle == "atr":
range_value = ATR(atr_length or length, matype=atr_matype)
elif bandstyle == "truerange":
range_value = TrueRange (no averaging)
elif bandstyle == "range":
range_value = WilderMA(high - low, atr_length or length)
upper = middle + (mult * range_value)
```
Examples
kc_up = kc_upper(close, 20, 2.0); # Standard KC upper
kc_up = kc_upper(close, 20, 2.0, matype="sma"); # SMA-based middle
kc_up = kc_upper(close, 20, 2.0, atr_length=14); # Different ATR period
kc_up = kc_upper(close, 20, 2.0, atr_matype="ema"); # EMA-smoothed ATR
kc_up = kc_upper(close, 20, 2.0, bandstyle="range"); # Wilder MA of range
close > kc_up; # Price above upper band (breakout)
Returns
Float value representing the upper band ## References - TradingView: Part of `ta.kc()` return values - Original Keltner used SMA and simple range - Modern version (Linda Bradford Raschke) uses EMA and ATR ## Notes - TradingView default: EMA middle with ATR bands - atr_length allows different smoothing for bands vs middle - bandstyle="range" mimics original Keltner formulation