Indicator · Pine Script v5 · Own pane

Keltner Center Of Gravity Channel Mutations Indicator

by regalouisei· code credited to eykpunter

The Keltner Center Of Gravity Channel Mutations Indicator calculates adaptive channel metrics based on Donchian range Fibonacci levels (38.2% and 61.8%) and Average True Range (ATR) offsets.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code94
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update8 months ago25 Feb 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

94 lines of Pine Script v5 from pinescript/editors_picks/kcgmut.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

kcgmut.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © eykpunter

//@version=5
indicator("Keltner Center Of Gravity Channel Mutations Indicator", shorttitle="KCGMut")

//calculate lookback
//script automatically adepts lookback to timeframe
per=14                               //initialize per
setper= 14                           //initialize setper
tf=timeframe.period
setper:= tf=="M"? 14: tf=="W"? 14: tf=="D"? 21: tf=="240"? 28: tf=="180"? 28: tf=="120"? 35: tf=="60"? 35: tf=="45"? 35: tf=="30"? 42: tf=="15"? 42: tf=="5"? 49: tf=="3"? 49: tf=="1"? 56: 10
per:= setper

//KeltCOG RELEVANT CODE
//Calculate channel
//Calculate COG
donhigh=ta.highest(high,per)           //COG calculated using values of Donchian channel
donlow=ta.lowest(low,per)
cent=(donhigh+donlow)/2             //center line not plotted, used calculation of widthpercent
donrange=donhigh-donlow
coglow=donlow+donrange*0.382        //Actually a Center Low fibonacci line in my donchian fibonacci channel
coghigh=donlow+donrange*0.618       //center high fibonacci

//Calculate borders
//calculate width (i.e. COG to border)
//script adepts width to lookback period
varwidth=2.00                           //initialize variable width
formula=math.round(2 + per/25 - 6/per, 1)    //Script uses this formula to adapt Width (i.e COG to border) to look back period
varwidth:= formula
dis=ta.atr(per)                        //Keltner channels have lines spaced by average true range
horizontal=false                    //Initialize horizontal boolean. New values only calculated when the COG (Center of Gravity) changes 

outerhigh=coghigh             //initialize Outer Keltner line above COG
outerlow=coglow               //initialize outer Kelner below COG
horizontal:= coglow==coglow[1]?true: false                //set horizontal COG changes result in Keltner changes, otherwize Keltner is horizontal
outerhigh:= horizontal?outerhigh[1]: coghigh+varwidth*dis
outerlow:= horizontal?outerlow[1]: coglow-varwidth*dis

//CALCULATE VALUES FOR INDICATOR
//define direction
trendup=close>coghigh
trenddown=close<coglow
trendside=close<=coghigh and close>=coglow

//define width percent of channel
widchan=outerhigh-outerlow
perchan = trendside? math.round(widchan/cent*25, 1): math.round(widchan/cent*50, 1) //indicator uses half of width, whisch is a little more than atr-percent
negperchan=-perchan

//define width percent of cog
widcog=coghigh-coglow
percog = trendside? math.round(widcog/cent*50, 1) :math.round(widcog/cent*100, 1)
negpercog = -percog

//CALCULATE VOLUME EXPANSION EVENTS
//Function finding the usual value of a series with a pick and choose statistical procedure, inspects 8 periods but averages the 'middlest' 4.
usual(src) =>                                            
    pick = math.sum(src,3) -ta.highest(src,3) -ta.lowest(src,3)    //pick the middle
    (math.sum(pick,6) -ta.highest(pick,6) -ta.lowest(pick,6))/4    //choose the mediocre out of the picks
// end of function

//finding volume events
usuvol= usual(volume) //find something to compare present volume with
relv= volume>usuvol? 100*(volume-usuvol)/volume :0     //only rises reported
eventbig=relv>50
event=relv>20 and relv<=50
evline=eventbig? widchan/cent*60 :event? widchan/cent*45: 0
negevline=eventbig? -widchan/cent*60 :event? -widchan/cent*35: 0
volcol = eventbig? color.blue: color.maroon

//firstplots
plot(evline,    title="volume event pos", color=volcol, style=plot.style_histogram, linewidth=2 )
plot(negevline, title="volume event neg", color=volcol, style=plot.style_histogram, linewidth=2 )

//PRAPARE AND EXECUTE PLOTS

//define swelling situations
chanswellup = widchan>widchan[1] and trendup
chanswelldown = widchan>widchan[1] and trenddown
chanswellside = widchan>widchan[1] and trendside
cogswellup = widcog>widcog[1] and trendup
cogswelldown = widcog>widcog[1] and trenddown
cogswellside = widcog>widcog[1] and trendside

//define colors
chancol = chanswellup? color.rgb(236, 177, 38, 00) : chanswelldown? color.maroon: chanswellside? color.rgb(245,124,00,00): trenddown? color.rgb(210,140,185,0): color.rgb(130,148,164,0)
cogcol = cogswellup ?  color.lime: cogswelldown? color.red: cogswellside? color.orange: color.black

//second plots
plot(trendup or trendside? perchan :na, title="channelwidth as percent of middle line", style=plot.style_columns, color=chancol)
plot(trendup or trendside? percog :na, title="COGwidth as percent of middle line", style=plot.style_columns, color=cogcol )
plot(trenddown or trendside? negperchan :na, title="channelwidth as percent negative", style=plot.style_columns, color=chancol )
plot(trenddown or trendside? negpercog :na, title="COGwidth as percent negative", style=plot.style_columns, color=cogcol )

Overview

The lookback period automatically adjusts according to the active timeframe, while channel width scales dynamically through a mathematical formula. It also detects relative volume spikes using a custom statistical smoothing function. The indicator plots channel width percentages and volume expansion event markers in a separate pane to visualize volatility and activity changes.

Details

Published by

regalouisei on GitHub

Code credit

eykpunter, as written in the script's header

Type

Indicator, Pine Script v5

Draws

Separate pane below the chart

Category

Volatility & bands, Volume, Support & resistance, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

This overlay indicator marks Wyckoff-style buying and selling climaxes on the price chart. It filters trend with an exponential moving average and a higher-timeframe EMA, then flags accumulation or distribution when price and ATR sit relative to their swing av

Indicator v6 TrendVolatility & bands
Updated 1 year ago · MIT GitHub repository of Ultimate Wyckoff Indicator V3 (Refined)

Crypto AMT Toolkit v2

by latifangren
1 stars

This indicator provides a comprehensive crypto trading toolkit on TradingView. It plots Volume Profile boxes using customizable lookback bars, row count, and value area percentage. VWAP lines with standard deviation bands are drawn alongside optional bands. Or

Indicator v6 VolumeVolatility & bands
Updated 5 months ago · MIT GitHub repository of Crypto AMT Toolkit v2
1 stars

This indicator combines Volume Weighted Bands, a Keltner Hull Suite, High Volume Nodes, and Supply and Demand Zones directly on the main price chart. It calculates a smoothed volume-weighted trend line surrounded by ATR-based bands to define market bias and hi

Indicator v6 TrendVolatility & bands
Updated 7 months ago · None stated GitHub repository of Keltner Hull Suite Integrated

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper

This indicator combines Chaikin Money Flow (CMF), a SuperTrend baseline, and an Average True Range (ATR) calculation inside a separate sub-pane. It calculates a standard 20-period CMF plotted as a line and colored histogram columns around a zero baseline, trac

Indicator v6 TrendVolume
Updated 6 months ago · Apache-2.0 GitHub repository of Institutional View: CMF & SuperTrend

Market Pressure Scale plots two oscillator curves in a separate pane. Setup pressure combines ATR and Bollinger compression, support and resistance proximity, and drying volume. Impulse pressure combines range expansion, volume, and candle body size. A range-c

Indicator v6 Oscillators & momentumVolatility & bands
Updated yesterday · MIT GitHub repository of Market Pressure Scale [WavesUnchained]

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers