Trend Bands [starlord_xrp]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © starlord_xrp

//@version=5
indicator("Trend Bands [starlord_xrp]", overlay = true)
ema9 = ta.ema(close, 9)
ema10 = ta.ema(close, 10)
ema12 = ta.ema(close, 12)
ema14 = ta.ema(close, 14)
ema16 = ta.ema(close, 16)
ema18 = ta.ema(close, 18)
ema20 = ta.ema(close, 20)
ema22 = ta.ema(close, 22)
ema24 = ta.ema(close, 24)
ema26 = ta.ema(close, 26)
ema28 = ta.ema(close, 28)
ema30 = ta.ema(close, 30)

color ema9_c = ta.rising(ema9, 1) ? color.green : color.red
color ema10_c = ta.rising(ema10, 1) ? color.green : color.red
color ema12_c = ta.rising(ema12, 1) ? color.green : color.red
color ema14_c = ta.rising(ema14, 1) ? color.green : color.red
color ema16_c = ta.rising(ema16, 1) ? color.green : color.red
color ema18_c = ta.rising(ema18, 1) ? color.green : color.red
color ema20_c = ta.rising(ema20, 1) ? color.green : color.red
color ema22_c = ta.rising(ema22, 1) ? color.green : color.red
color ema24_c = ta.rising(ema24, 1) ? color.green : color.red
color ema26_c = ta.rising(ema26, 1) ? color.green : color.red
color ema28_c = ta.rising(ema28, 1) ? color.green : color.red
color ema30_c = ta.rising(ema30, 1) ? color.green : color.red

plot(ema9, color=ema9_c)
plot(ema10, color=ema10_c)
plot(ema12, color=ema12_c)
plot(ema14, color=ema14_c)
plot(ema16, color=ema16_c)
plot(ema18, color=ema18_c)
plot(ema20, color=ema20_c)
plot(ema22, color=ema22_c)
plot(ema24, color=ema24_c)
plot(ema26, color=ema26_c)
plot(ema28, color=ema28_c)
plot(ema30, color=ema30_c)

int green_count = 0

if ema9_c == color.green
    green_count += 1

if ema10_c == color.green
    green_count += 1

if ema12_c == color.green
    green_count += 1

if ema14_c == color.green
    green_count += 1

if ema16_c == color.green
    green_count += 1

if ema18_c == color.green
    green_count += 1

if ema20_c == color.green
    green_count += 1

if ema22_c == color.green
    green_count += 1

if ema24_c == color.green
    green_count += 1

if ema26_c == color.green
    green_count += 1

if ema28_c == color.green
    green_count += 1

if ema30_c == color.green
    green_count += 1

color bar_color = na

//plot (green_count, "green count")
if green_count > 5 and green_count < 12
    bar_color := color.green
else if (green_count == 12)
    bar_color := color.lime
else if green_count == 5
    bar_color := color.yellow
else if green_count < 5 and green_count > 0
    bar_color := color.red
else if green_count == 0
    bar_color := color.maroon

bool short_pullback = na
bool long_pullback = na

if green_count[1] < 5 and green_count[2] < 5 and ta.crossunder(green_count, 1)
    short_pullback := true

if green_count[1] > 5 and green_count[2] > 5 and ta.crossover(green_count, 11)
    long_pullback := true

ema200 = ta.ema(close, 200)
ema200_std_dif_low = ema200+(ema200*0.005)
ema200_std_dif_high = ema200-(ema200*0.005)

plot(ema200, "ema200", color.silver, 3)
plotshape(long_pullback, "Pullback", shape.diamond, location.abovebar, color.teal, 0, "Pullback")
plotshape(short_pullback, "Pullback", shape.diamond, location.belowbar, color.teal, 0, "Pullback")
barcolor(bar_color)