LNL Keltner Exhaustion
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
// @version=5
//
// L&L Keltner Exhaustion
//
// With the Keltner Exhaustion wedges, you can easily see the Keltner Channel extremes witout using the actual bands. This resolves the constant issue of Bands vs. EMAs
//
// The defaults are set to 3 ATR and 4 ATR (the extremes are set to purple)
//
// Created by © L&L Capital
// 

indicator(title="LNL Keltner Exhaustion", shorttitle = "Keltner Exhaustion", overlay=true)

// Inputs

length = input(21, title = "MidLine Keltner Length")
atrlength = input(21, title = "ATR Keltner Length")
mult = input(3, title = "ATR Keltner Factor")
mult1 = input(4, title = "ATR Keltner Factor Extreme")

// Keltner Calculations

ma = ta.ema(close, length)
rangema = ta.ema(ta.tr, atrlength)
upper = ma + rangema * mult // UPPER MID BAND
lower = ma - rangema * mult // LOWER MID BAND
upperX = ma + rangema * mult1 // UPPER MID BAND EXTREME
lowerX = ma - rangema * mult1 // LOWER MID BAND EXTREME

// Plots

UpperKeltner = high > upper
plotchar(UpperKeltner, title = "Upper Keltner", char = '˄', location = location.abovebar, size = size.tiny, color = #ff0000)

LowerKeltner = low < lower
plotchar(LowerKeltner, title = "Lower Keltner", char = '˅', location = location.belowbar, size = size.tiny, color = #009900)

UpperKeltnerX = high > upperX
plotchar(UpperKeltnerX, title = "Upper Keltner Extreme", char = '˄', location = location.abovebar, size = size.tiny, color = #bd53ce)

LowerKeltnerX = low < lowerX
plotchar(LowerKeltnerX, title = "Lower Keltner Extreme", char = '˅', location = location.belowbar, size = size.tiny, color = #bd53ce)

// EMAs

ema8 = input.int(defval=8, title='EMA Length')
ema13 = input.int(defval=13, title='EMA Length')
ema21 = input.int(defval=21, title='EMA Length')
ema34 = input.int(defval=34,  title='EMA Length')
ema55 = input.int(defval=55,  title='EMA Length')
ema89 = input.int(defval=89,title='EMA Length')
ema200 = input.int(defval=200,  title='EMA Length')

ema8d =  ta.ema(close, ema8)
ema13d = ta.ema(close, ema13)
ema21d = ta.ema(close, ema21)
ema34d = ta.ema(close, ema34)
ema55d = ta.ema(close, ema55)
ema89d = ta.ema(close, ema89)
ema200d = ta.ema(close, ema200)

plot(ema8d, title='EMA 8', color=color.new(color.green, 0), linewidth=1, display = display.none)
plot(ema13d, title='EMA 13', color=color.new(color.orange, 0), linewidth=1, display = display.none)
plot(ema21d, title='EMA 21', color=color.new(color.yellow, 0), linewidth=2, display = display.none)
plot(ema34d, title='EMA 34', color=color.new(color.purple, 0), linewidth=1, display = display.none)
plot(ema55d, title='EMA 55', color=color.new(color.red, 0), linewidth=1, display = display.none)
plot(ema89d, title='EMA 89', color=color.new(color.aqua, 0), linewidth=1, display = display.none)
plot(ema200d, title='EMA 200', color=color.new(color.blue, 0), linewidth=2, display = display.none)

