kc_upper
Keltner Channels Upper Band
kc_upper(source, length, mult, matype="ema", atr_length=..., atr_matype="wilder", bandstyle="atr")
Parameters
Keltner Channels Upper Band - kc_upper(source, length, mult, matype="ema", atr_length=None, atr_matype="wilder", bandstyle="atr")
Volatility-based upper band using MA and range-based volatility measure.
- source (field): Price field for middle line calculation (typically close)
- Valid inputs: close, open, high, low, or any indicator output
- length (int): Period for middle line MA calculation
- Common values: 20, 10, 50
- mult (float): Multiplier for band width
- Common values: 2.0, 1.5, 2.5
- matype (str, optional): MA type for middle line
- Valid options: ["ema", "sma", "wma", "wilder"]
- Default: "ema"
- atr_length (int, optional): Period for volatility calculation (ATR/range)
- Default: None (uses same as length)
- Allows independent control of band smoothing
- atr_matype (str, optional): MA type for ATR smoothing
- Valid options: ["wilder", "sma", "ema"]
- Default: "wilder" (traditional ATR)
- bandstyle (str, optional): Volatility measurement method
- "atr": Use ATR (average true range) - TradingView default
- "truerange": Use raw true range (no averaging)
- "range": Use Wilder MA of (high - low)
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