Indicator · Pine Script v4 · On the chart

Hull Keltner Channel

by cryptorife

Hull Keltner Channel calculates and plots a customized Keltner Channel overlaid directly on the price chart.

View on GitHub

GitHub stars75on the repository
Pine versionv4older, still runs
Lines of code82
Settings15inputs
LicenceGPL-3.0
Last update3 years ago17 Mar 2023

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

82 lines of Pine Script v4 from hull_keltner_channel.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

hull_keltner_channel.pine
// Keltner Channel using @insilico's Hull Suite as Moving Average source, with 2 pairs of envelops.
//@version=4

study(title="Hull Keltner Channel", shorttitle="HKCB", overlay=true)

// HULL INPUT
src = input(close, title="Hull's Source")
modeSwitch = input("Hma", title="Hull Variation", options=["Hma", "Thma", "Ehma"])
lengthHull = input(55, title="Length(180-200 for floating S/R , 55 for swing entry)")
lengthMult = input(1.0, title="Length multiplier (Used to view higher timeframes with straight band)")

useHtf = input(false, title="Show Hull MA from X timeframe? (good for scalping)")
htf = input("240", title="Higher timeframe", type=input.resolution)

switchColor = input(true, "Color Hull according to trend?")
candleCol = input(false,title="Color candles based on Hull's Trend?")
visualSwitch  = input(true, title="Show as a Band?")
thicknesSwitch = input(1, title="Line Thickness")
transpSwitch = input(40, title="Band Transparency",step=5)

// HULL FUNCTIONS

//HMA
HMA(_src, _length) =>  wma(2 * wma(_src, _length / 2) - wma(_src, _length), round(sqrt(_length)))
//EHMA    
EHMA(_src, _length) =>  ema(2 * ema(_src, _length / 2) - ema(_src, _length), round(sqrt(_length)))
//THMA    
THMA(_src, _length) =>  wma(wma(_src,_length / 3) * 3 - wma(_src, _length / 2) - wma(_src, _length), _length)
    
//SWITCH
Mode(modeSwitch, src, len) =>
      modeSwitch == "Hma"  ? HMA(src, len) :
      modeSwitch == "Ehma" ? EHMA(src, len) : 
      modeSwitch == "Thma" ? THMA(src, len/2) : na

//OUT
_hull = Mode(modeSwitch, src, int(lengthHull * lengthMult))
HULL = useHtf ? security(syminfo.ticker, htf, _hull) : _hull
MHULL = HULL[0]
SHULL = HULL[2]

//COLOR
hullColor = switchColor ? (HULL > HULL[2] ? #00ff00 : #ff0000) : #ff9800

//PLOT
///< Frame
Fi1 = plot(MHULL, title="MHULL", color=hullColor, linewidth=thicknesSwitch, transp=50)
Fi2 = plot(visualSwitch ? SHULL : na, title="SHULL", color=hullColor, linewidth=thicknesSwitch, transp=50)
///< Ending Filler
fill(Fi1, Fi2, title="Band Filler", color=hullColor, transp=transpSwitch)
///BARCOLOR
barcolor(color = candleCol ? (switchColor ? hullColor : na) : na)

// KELTNER BAND

useATR = input(true)
multiplier = input(2.0)
multiplier2 = input(4.0)
length = input(200, minval=1)

pine_atr(length) =>
    h = useHtf ? security(syminfo.ticker, htf, high) : high
    l = useHtf ? security(syminfo.ticker, htf, low) : low
    c = useHtf ? security(syminfo.ticker, htf, close[1]) : close[1]
    trueRange = na(h[1])? h-l : max(max(h - l, abs(h - c)), abs(l - c))
    rma(trueRange, length)

ma = HULL
range = useATR ? pine_atr(length) : high - low
rangema = ema(range, length)
upper = ma + rangema * multiplier
lower = ma - rangema * multiplier
upper2 = ma + rangema * multiplier2
lower2 = ma - rangema * multiplier2

u = plot(upper, color=color.orange, title="Upper 1", transp=50)
u2 = plot(upper2, color=color.red, title="Upper 2", transp=50)
plot(ma, color=color.black, title="Moving Average")
l = plot(lower, color=color.orange, title="Lower 1", transp=50)
l2 = plot(lower2, color=color.red, title="Lower 2", transp=50)
fill(u, l, color=color.purple, transp=95)
fill(u2, l2, color=color.purple, transp=90)

Overview

Hull Keltner Channel replaces the traditional moving average baseline with a Hull Moving Average variation, offering standard HMA, exponential EHMA, and triple THMA options. Two sets of upper and lower envelope bands are calculated using ATR or high-low range multipliers. Users can toggle higher-timeframe data fetching, adjust Hull lengths and multipliers, display the baseline as a shaded band, and color both the Hull baseline and price bars according to trend direction.

Details

Published by

cryptorife on GitHub

Type

Indicator, Pine Script v4

Draws

On the price chart

Category

Moving averages, Volatility & bands, 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.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Hull's Sourcesourceclosesrc
Hull VariationstringHmamodeSwitch
Length(180-200 for floating S/R , 55 for swing entry)int55lengthHull
Length multiplier (Used to view higher timeframes with straight band)float1.0lengthMult
Show Hull MA from X timeframe? (good for scalping)boolfalseuseHtf
Higher timeframetimeframe240htf
Color Hull according to trend?booltrueswitchColor
Color candles based on Hull's Trend?boolfalsecandleCol
Show as a Band?booltruevisualSwitch
Line Thicknessint1thicknesSwitch
Band Transparencyint40transpSwitch
useATRbooltrueuseATR
Show all 15 settings
SettingTypeDefaultVariable
multiplierfloat2.0multiplier
multiplier2float4.0multiplier2
lengthint200length
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

318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

Bollinger Bands Force

by harryguiacorn
219 stars

This indicator modifies standard Bollinger Bands to measure directional trend force based on line alignment. It calculates a simple moving average basis along with upper and lower volatility bands. When all three lines move upward or downward simultaneously, i

Indicator v5 Volatility & bandsTrend
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Force

Adaptive MA Slope

by capissimo
114 stars

This indicator calculates Kaufman's Adaptive Moving Average (KAMA) on a chosen price source and determines trend direction based on the slope across a configurable lookback window. Signals can be filtered by short-term volatility expansion using ATR comparison

Indicator v4 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of Adaptive MA Slope

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