Trading Made Easy ATR Bands
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © christoefert

//@version=5

//Keltner ATR Bands
indicator(title="Trading Made Easy ATR Bands", shorttitle="TME ATR Bands", overlay=true, timeframe="", timeframe_gaps=true)
length = input.int(21, minval=1)
mult = input(1.0, "Multiplier")
src = input(ohlc4, title="Source")
exp = input(true, "Use Exponential MA")
BandsStyle = input.string("Average True Range", options = ["Average True Range", "True Range", "Range"], title="Bands Style")
atrlength = input(10, "ATR Length")
esma(source, length)=>
	s = ta.sma(source, length)
	e = ta.ema(source, length)
	exp ? e : s
ma = esma(src, length)
rangema = BandsStyle == "True Range" ? ta.tr(true) : BandsStyle == "Average True Range" ? ta.atr(atrlength) : ta.rma(high - low, length)
upper = ma + rangema * mult
lower = ma - rangema * mult
upper2 = ma + rangema * (mult * 2)
lower2 = ma - rangema * (mult * 2)
upper3 = ma + rangema * (mult * 3)
lower3 = ma - rangema * (mult * 3)
upper4 = ma + rangema * (mult * 4)
lower4 = ma - rangema * (mult * 4)

u = plot(upper, color=color.green, title="1 ATR Up")
plot(ma, color=color.white, title="ATR Band Basis")
l = plot(lower, color=color.green, title="1 ATR Down")
fill(u, l, color=color.green, title="1 ATR Zone")
u2 = plot(upper2, color=color.blue, title="2 ATR Up")
l2 = plot(lower2, color=color.blue, title="2 ATR Down")
fill(u, u2, color=color.blue, title="2 ATR Zone Up Zone")
fill(l, l2, color=color.blue, title="2 ATR Zone Down Zone")
u3 = plot(upper3, color=color.orange, title="3 ATR Up")
l3 = plot(lower3, color=color.orange, title="3 ATR Down")
fill(u2, u3, color=color.orange, title="3 ATR Up Zone")
fill(l2, l3, color=color.orange, title="3 ATR Down Zone")
u4 = plot(upper4, color=color.red, title="4 ATR Up")
l4 = plot(lower4, color=color.red, title="4 ATR Down")
fill(u3, u4, color=color.red, title="4 ATR Up Zone")
fill(l3, l4, color=color.red, title="4 ATR Down Zone")

//Stack'Em Fibonacci EMAs

First = ta.ema(ohlc4, 8)
plot(First, title="8 EMA", color=color.green)
Second = ta.ema(ohlc4, 13)
plot(Second, title="13 EMA", color=color.blue)
Third = ta.ema(ohlc4, 34)
plot(Third, title="34 EMA", color=color.yellow)
Fourth = ta.ema(ohlc4, 55)
plot(Fourth, title="55 EMA", color=color.purple)
Fifth = ta.ema(ohlc4, 89)
plot(Fifth, title="89 EMA", color=color.white)
Sixth = ta.ema(ohlc4, 144)
plot(Sixth, title="144 EMA", color=color.red)

// Directional Movement Trend Bars

len = input.int(14, minval=1, title="DI Length")
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = ta.rma(ta.tr, len)
plus = fixnan(100 * ta.rma(plusDM, len) / trur)
minus = fixnan(100 * ta.rma(minusDM, len) / trur)
sum = plus + minus

Strong_Up = plus >= 20 and plus > minus and ma[0] > ma[1]
Strong_Down = minus >= 20 and minus > plus and ma[0] < ma[1]
WeakUp = (plus > minus and plus < 20 and ma[0] <= ma[1]) or (plus > minus and plus < 20 and ma[0] > ma[1]) or (minus > plus and ma[0] > ma[1])
WeakDown = (minus > plus and minus < 20 and ma[0] >= ma[1]) or (minus > plus and minus < 20 and ma[0] < ma[1]) or (plus > minus and ma[0] < ma[1])

barcolor(Strong_Up ? color.lime : WeakUp ? color.blue : Strong_Down ? color.red : WeakDown ? color.orange : na)