kcw

Keltner Channels Width (percentage)

kcw(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_matype str, optional MA type for ATR smoothing
bandstyle str, optional Volatility measurement method

Formula

```
middle = MA(source, length, matype)
upper = kc_upper(source, length, mult, ...)
lower = kc_lower(source, length, mult, ...)
width = ((upper - lower) / middle) * 100
```

Examples

kcw_value = kcw(close, 20, 2.0);
kcw_value < 10;  # Narrow channels (low volatility, potential breakout)
kcw_value > 30;  # Wide channels (high volatility)

# Squeeze detection (compare with Bollinger Bands Width)
kc_width = kcw(close, 20, 2.0);
bb_width = bb_width(close, 20, 2.0);
kc_width < bb_width;  # Squeeze condition

Returns

Float value representing channel width as percentage of middle line - Higher values indicate higher volatility (wider channels) - Lower values indicate lower volatility (narrower channels) - Useful for identifying volatility contraction/expansion ## References - TradingView: `ta.kcw(source, length, mult, useTrueRange)` - Derived from Keltner Channels - Often used with BBW for squeeze detection ## Notes - Width expressed as percentage for cross-asset comparisons - Low values often precede significant price moves - Can be used to filter trend-following signals - All kwargs are passed through to KC upper/lower/middle calculations