VolatilityPine Script v6

ta.kc()Keltner Channels

Keltner channel is a technical analysis indicator showing a central moving average line plus channel lines at a distance above and below.

Syntax

Syntax
ta.kc(series, length, mult, usetruerange) → [series float, series float, series float]

Arguments

ParameterTypeDescription
seriesseries int/floatSource series (typically price).
lengthsimple intLength for the central average and band calculation.
multsimple int/floatMultiplier applied to the range measure.
usetruerangesimple boolOptional. If true, uses true range in the band width; default true.

Returns

Keltner Channels.

Remarks

Returns middle, upper, and lower channel values. The default uses true range for volatility in the channel width when usetruerange is true.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.kc")

[middle, upper, lower] = ta.kc(close, 5, 4)
plot(middle, color=color.yellow)
plot(upper, color=color.yellow)
plot(lower, color=color.yellow)

Trading Applications

Identify trend direction using channel slope

Detect overbought/oversold with price at channel extremes

Combine with Bollinger Bands for squeeze detection

Use as dynamic support and resistance levels

Related Functions

Frequently Asked Questions

ta.kc() builds Keltner Channels: a middle line (typically EMA-based) with upper and lower bands offset by a multiple of average range (often ATR or true range depending on settings).

Bollinger Bands use standard deviation around an SMA, so width reflects statistical dispersion. Keltner Channels use a fixed multiple of range (e.g., ATR) around an EMA, so width reflects average bar range more directly.

The TTM Squeeze idea compares when Bollinger Bands move inside Keltner Channels (low volatility compression) versus when they expand outside (potential volatility expansion). Implementations vary; confirm logic in your script or platform.

Generate ta.kc() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.kc() and other built-in functions instantly.