Seasonal - Trading Day of Month
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sammypi

//@version=5
indicator("Seasonal", overlay = true)

i_position = input.string("bottom_right", "Position", options=["top_left", "top_center", "top_right", "middle_left", "middle_center", "middle_right", "bottom_left", "bottom_center", "bottom_right"])

position = switch i_position
    "top_left"       => position.top_left
    "top_center"     => position.top_center
    "top_right"      => position.top_right
    "middle_left"    => position.middle_left
    "middle_center"  => position.middle_center
    "middle_right"   => position.middle_right
    "bottom_left"    => position.bottom_left
    "bottom_center"  => position.bottom_center
    "bottom_right"   => position.bottom_right
    // Default used when none of the options match
    => position.top_left

//-----timeframe
year_cal = input(2022, title="Must be the last year", tooltip = "You Should check with CLOSE Data if the first Trading Day of Month in the Matrix is the 31. of prior Month or the 1. of current Month", group = "Timeframe Input (MAX 32 Columns)")
month_start = input(5, title="Month", tooltip = "To get the first TradingDay of Month you have to set the StartPoint to 31. of the prior Month or 1. of current Month")
month_end = input(6)
day_start = input(31, title="Day", tooltip = "To get the first TradingDay of Month you have to set the StartPoint to 31. of the prior Month or 1. of current Month")
day_end = input(31)



//-----Color
gradient_upcolor_weak = input(color.rgb(0, 140, 255, 80))
gradient_upcolor_strong = input(color.rgb(0, 255, 8, 80))
gradient_downcolor_weak = input(color.rgb(255, 0, 225, 80))
gradient_downcolor_strong = input(color.rgb(246, 0, 0, 80))

gradient_upcolor_weak_bar = input(color.rgb(0, 140, 255, 40))
gradient_upcolor_strong_bar = input(color.rgb(0, 255, 8, 40))
gradient_downcolor_weak_bar = input(color.rgb(255, 0, 225, 40))
gradient_downcolor_strong_bar = input(color.rgb(246, 0, 0, 40))

channel_upcolor = input(color.rgb(57, 132, 60))
channel_upcolor_power = input(color.rgb(19, 204, 53))
channel_downcolor = input(color.rgb(169, 58, 58))
channel_downcolor_power = input(color.rgb(227, 11, 47))
channel_neutralcolor = input(color.gray)

//-----arrayinput 
data_input = input.string("Percent Change", title="Data from...", options = ["Percent Change", "Close", "Close-Open"])
data_source(type) =>
    switch type
        "Percent Change" => (close - open) / open * 100
        "Close" => close
        "Close-Open" => close-open

ma = data_source(data_input) 



//-----array this year 
startDateTime0 = timestamp(year_cal+1, month_start, day_start, 00, 00)
endDateTime0 = timestamp(year_cal+1, month_end, day_end, 23, 59)
inDateAndTimeRange0 = (time >= startDateTime0) and (time < endDateTime0)
showClose0 = inDateAndTimeRange0 ? ma : na 

//-----array last year 
startDateTime1 = timestamp(year_cal, month_start, day_start, 00, 00)
endDateTime1 = timestamp(year_cal, month_end, day_end, 23, 59)
inDateAndTimeRange1 = (time >= startDateTime1) and (time < endDateTime1)
showClose1 = inDateAndTimeRange1 ? ma : na 


//-----array last year-1
startDateTime2 = timestamp(year_cal-1, month_start, day_start, 00, 00)
endDateTime2 = timestamp(year_cal-1, month_end, day_end, 23, 59)
inDateAndTimeRange2 = (time >= startDateTime2) and (time < endDateTime2)
showClose2 = inDateAndTimeRange2 ? ma  : na 

//-----array last year-2
startDateTime3 = timestamp(year_cal-2, month_start, day_start, 00, 00)
endDateTime3 = timestamp(year_cal-2, month_end, day_end, 23, 59)
inDateAndTimeRange3 = (time >= startDateTime3) and (time < endDateTime3)
showClose3 = inDateAndTimeRange3 ? ma  : na 

//-----array last year-3
startDateTime4 = timestamp(year_cal-3, month_start, day_start, 00, 00)
endDateTime4 = timestamp(year_cal-3, month_end, day_end, 23, 59)
inDateAndTimeRange4 = (time >= startDateTime4) and (time < endDateTime4)
showClose4 = inDateAndTimeRange4 ? ma  : na 

//-----array last year-4
startDateTime5 = timestamp(year_cal-4, month_start, day_start, 00, 00)
endDateTime5 = timestamp(year_cal-4, month_end, day_end, 23, 59)
inDateAndTimeRange5 = (time >= startDateTime5) and (time < endDateTime5)
showClose5 = inDateAndTimeRange5 ? ma  : na 

//-----array last year-5
startDateTime6 = timestamp(year_cal-5, month_start, day_start, 00, 00)
endDateTime6 = timestamp(year_cal-5, month_end, day_end, 23, 59)
inDateAndTimeRange6 = (time >= startDateTime6) and (time < endDateTime6)
showClose6 = inDateAndTimeRange6 ? ma  : na 

//-----array last year-6
startDateTime7 = timestamp(year_cal-6, month_start, day_start, 00, 00)
endDateTime7 = timestamp(year_cal-6, month_end, day_end, 23, 59)
inDateAndTimeRange7 = (time >= startDateTime7) and (time < endDateTime7)
showClose7 = inDateAndTimeRange7 ? ma  : na 

//-----array last year-7
startDateTime8 = timestamp(year_cal-7, month_start, day_start, 00, 00)
endDateTime8 = timestamp(year_cal-7, month_end, day_end, 23, 59)
inDateAndTimeRange8 = (time >= startDateTime8) and (time < endDateTime8)
showClose8 = inDateAndTimeRange8 ? ma  : na 

//-----array last year-8
startDateTime9 = timestamp(year_cal-8, month_start, day_start, 00, 00)
endDateTime9 = timestamp(year_cal-8, month_end, day_end, 23, 59)
inDateAndTimeRange9 = (time >= startDateTime9) and (time < endDateTime9)
showClose9 = inDateAndTimeRange9 ? ma  : na 

//-----array last year-9
startDateTime10 = timestamp(year_cal-9, month_start, day_start, 00, 00)
endDateTime10 = timestamp(year_cal-9, month_end, day_end, 23, 59)
inDateAndTimeRange10 = (time >= startDateTime10) and (time < endDateTime10)
showClose10 = inDateAndTimeRange10 ? ma  : na 

//-----array last year-10
startDateTime11 = timestamp(year_cal-10, month_start, day_start, 00, 00)
endDateTime11 = timestamp(year_cal-10, month_end, day_end, 23, 59)
inDateAndTimeRange11 = (time >= startDateTime11) and (time < endDateTime11)
showClose11 = inDateAndTimeRange11 ? ma  : na 


//-----arrays variable
var float [] sumClose00 = array.new_float(0)

var float [] sumClose0 = array.new_float(0)
var float [] sumClose1 = array.new_float(0)
var float [] sumClose2 = array.new_float(0)
var float [] sumClose3 = array.new_float(0)
var float [] sumClose4 = array.new_float(0)
var float [] sumClose5 = array.new_float(0)
var float [] sumClose6 = array.new_float(0)
var float [] sumClose7 = array.new_float(0)
var float [] sumClose8 = array.new_float(0)
var float [] sumClose9 = array.new_float(0)
var float [] sumClose10 = array.new_float(0)


var float [] check = array.new_float(0)
if showClose1
    array.push(check, close)

if showClose0
    array.push(sumClose00, ma)
size0 = array.size(sumClose00)

if showClose1
    array.push(sumClose1, ma)
size1 = array.size(sumClose1)

if showClose2
    array.push(sumClose2, ma)
size2 = array.size(sumClose2)

if showClose3
    array.push(sumClose3, ma)
size3 = array.size(sumClose3)

if showClose4
    array.push(sumClose4, ma)
size4 = array.size(sumClose4)

if showClose5
    array.push(sumClose5, ma)
size5 = array.size(sumClose5)

if showClose6
    array.push(sumClose6, ma)
size6 = array.size(sumClose6)

if showClose7
    array.push(sumClose7, ma)
size7 = array.size(sumClose7)

if showClose8
    array.push(sumClose8, ma)
size8 = array.size(sumClose8)

if showClose9
    array.push(sumClose9, ma)
size9 = array.size(sumClose9)

if showClose10
    array.push(sumClose10, ma)
size10 = array.size(sumClose10)
 

get_index_values0 = array.new_float(0)
get_index_values1 = array.new_float(0)
get_index_values2 = array.new_float(0)
get_index_values3 = array.new_float(0)
get_index_values4 = array.new_float(0)
get_index_values5 = array.new_float(0)
get_index_values6 = array.new_float(0)
get_index_values7 = array.new_float(0)
get_index_values8 = array.new_float(0)
get_index_values9 = array.new_float(0)
get_index_values10 = array.new_float(0)
get_index_values11 = array.new_float(0)
get_index_values12 = array.new_float(0)
get_index_values13 = array.new_float(0)
get_index_values14 = array.new_float(0)
get_index_values15 = array.new_float(0)
get_index_values16 = array.new_float(0)
get_index_values17 = array.new_float(0)
get_index_values18 = array.new_float(0)
get_index_values19 = array.new_float(0)
get_index_values20 = array.new_float(0)
get_index_values21 = array.new_float(0)
get_index_values22 = array.new_float(0)
get_index_values23 = array.new_float(0)
get_index_values24 = array.new_float(0)
get_index_values25 = array.new_float(0)
get_index_values26 = array.new_float(0)
get_index_values27 = array.new_float(0)
get_index_values28 = array.new_float(0)
get_index_values29 = array.new_float(0)
get_index_values30 = array.new_float(0)


//---sumClose1 array
if array.size(sumClose1) > 0
    array.push(get_index_values0, array.get(sumClose1, 0))
if array.size(sumClose1) > 1
    array.push(get_index_values1, array.get(sumClose1, 1))
if array.size(sumClose1) > 2
    array.push(get_index_values2, array.get(sumClose1, 2))
if array.size(sumClose1) > 3
    array.push(get_index_values3, array.get(sumClose1, 3))    
if array.size(sumClose1) > 4
    array.push(get_index_values4, array.get(sumClose1, 4))
if array.size(sumClose1) > 5
    array.push(get_index_values5, array.get(sumClose1, 5))
if array.size(sumClose1) > 6
    array.push(get_index_values6, array.get(sumClose1, 6))
if array.size(sumClose1) > 7
    array.push(get_index_values7, array.get(sumClose1, 7))
if array.size(sumClose1) > 8
    array.push(get_index_values8, array.get(sumClose1, 8))
if array.size(sumClose1) > 9
    array.push(get_index_values9, array.get(sumClose1, 9))
if array.size(sumClose1) > 10
    array.push(get_index_values10, array.get(sumClose1, 10))
if array.size(sumClose1) > 11
    array.push(get_index_values11, array.get(sumClose1, 11))
if array.size(sumClose1) > 12
    array.push(get_index_values12, array.get(sumClose1, 12))
if array.size(sumClose1) > 13
    array.push(get_index_values13, array.get(sumClose1, 13))    
if array.size(sumClose1) > 14
    array.push(get_index_values14, array.get(sumClose1, 14))
if array.size(sumClose1) > 15
    array.push(get_index_values15, array.get(sumClose1, 15))
if array.size(sumClose1) > 16
    array.push(get_index_values16, array.get(sumClose1, 16))
if array.size(sumClose1) > 17
    array.push(get_index_values17, array.get(sumClose1, 17))
if array.size(sumClose1) > 18
    array.push(get_index_values18, array.get(sumClose1, 18))
if array.size(sumClose1) > 19
    array.push(get_index_values19, array.get(sumClose1, 19))
if array.size(sumClose1) > 20
    array.push(get_index_values20, array.get(sumClose1, 20))
if array.size(sumClose1) > 21
    array.push(get_index_values21, array.get(sumClose1, 21))
if array.size(sumClose1) > 22
    array.push(get_index_values22, array.get(sumClose1, 22))
if array.size(sumClose1) > 23
    array.push(get_index_values23, array.get(sumClose1, 23))    
if array.size(sumClose1) > 24
    array.push(get_index_values24, array.get(sumClose1, 24))
if array.size(sumClose1) > 25
    array.push(get_index_values25, array.get(sumClose1, 25))
if array.size(sumClose1) > 26
    array.push(get_index_values26, array.get(sumClose1, 26))
if array.size(sumClose1) > 27
    array.push(get_index_values27, array.get(sumClose1, 27))
if array.size(sumClose1) > 28
    array.push(get_index_values28, array.get(sumClose1, 28))
if array.size(sumClose1) > 29
    array.push(get_index_values29, array.get(sumClose1, 29))
if array.size(sumClose1) > 30
    array.push(get_index_values30, array.get(sumClose1, 30))

//---sumClose2 array
if array.size(sumClose2) > 0
    array.push(get_index_values0, array.get(sumClose2, 0))
if array.size(sumClose2) > 1
    array.push(get_index_values1, array.get(sumClose2, 1))
if array.size(sumClose2) > 2
    array.push(get_index_values2, array.get(sumClose2, 2))
if array.size(sumClose2) > 3
    array.push(get_index_values3, array.get(sumClose2, 3))    
if array.size(sumClose2) > 4
    array.push(get_index_values4, array.get(sumClose2, 4))
if array.size(sumClose2) > 5
    array.push(get_index_values5, array.get(sumClose2, 5))
if array.size(sumClose2) > 6
    array.push(get_index_values6, array.get(sumClose2, 6))
if array.size(sumClose2) > 7
    array.push(get_index_values7, array.get(sumClose2, 7))
if array.size(sumClose2) > 8
    array.push(get_index_values8, array.get(sumClose2, 8))
if array.size(sumClose2) > 9
    array.push(get_index_values9, array.get(sumClose2, 9))
if array.size(sumClose2) > 10
    array.push(get_index_values10, array.get(sumClose2, 10))
if array.size(sumClose2) > 11
    array.push(get_index_values11, array.get(sumClose2, 11))
if array.size(sumClose2) > 12
    array.push(get_index_values12, array.get(sumClose2, 12))
if array.size(sumClose2) > 13
    array.push(get_index_values13, array.get(sumClose2, 13))    
if array.size(sumClose2) > 14
    array.push(get_index_values14, array.get(sumClose2, 14))
if array.size(sumClose2) > 15
    array.push(get_index_values15, array.get(sumClose2, 15))
if array.size(sumClose2) > 16
    array.push(get_index_values16, array.get(sumClose2, 16))
if array.size(sumClose2) > 17
    array.push(get_index_values17, array.get(sumClose2, 17))
if array.size(sumClose2) > 18
    array.push(get_index_values18, array.get(sumClose2, 18))
if array.size(sumClose2) > 19
    array.push(get_index_values19, array.get(sumClose2, 19))
if array.size(sumClose2) > 20
    array.push(get_index_values20, array.get(sumClose2, 20))
if array.size(sumClose2) > 21
    array.push(get_index_values21, array.get(sumClose2, 21))
if array.size(sumClose2) > 22
    array.push(get_index_values22, array.get(sumClose2, 22))
if array.size(sumClose2) > 23
    array.push(get_index_values23, array.get(sumClose2, 23))    
if array.size(sumClose2) > 24
    array.push(get_index_values24, array.get(sumClose2, 24))
if array.size(sumClose2) > 25
    array.push(get_index_values25, array.get(sumClose2, 25))
if array.size(sumClose2) > 26
    array.push(get_index_values26, array.get(sumClose2, 26))
if array.size(sumClose2) > 27
    array.push(get_index_values27, array.get(sumClose2, 27))
if array.size(sumClose2) > 28
    array.push(get_index_values28, array.get(sumClose2, 28))
if array.size(sumClose2) > 29
    array.push(get_index_values29, array.get(sumClose2, 29))
if array.size(sumClose2) > 30
    array.push(get_index_values30, array.get(sumClose2, 30))

//---sumClose3 array
if array.size(sumClose3) > 0
    array.push(get_index_values0, array.get(sumClose3, 0))
if array.size(sumClose3) > 1
    array.push(get_index_values1, array.get(sumClose3, 1))
if array.size(sumClose3) > 2
    array.push(get_index_values2, array.get(sumClose3, 2))
if array.size(sumClose3) > 3
    array.push(get_index_values3, array.get(sumClose3, 3))    
if array.size(sumClose3) > 4
    array.push(get_index_values4, array.get(sumClose3, 4))
if array.size(sumClose3) > 5
    array.push(get_index_values5, array.get(sumClose3, 5))
if array.size(sumClose3) > 6
    array.push(get_index_values6, array.get(sumClose3, 6))
if array.size(sumClose3) > 7
    array.push(get_index_values7, array.get(sumClose3, 7))
if array.size(sumClose3) > 8
    array.push(get_index_values8, array.get(sumClose3, 8))
if array.size(sumClose3) > 9
    array.push(get_index_values9, array.get(sumClose3, 9))
if array.size(sumClose3) > 10
    array.push(get_index_values10, array.get(sumClose3, 10))
if array.size(sumClose3) > 11
    array.push(get_index_values11, array.get(sumClose3, 11))
if array.size(sumClose3) > 12
    array.push(get_index_values12, array.get(sumClose3, 12))
if array.size(sumClose3) > 13
    array.push(get_index_values13, array.get(sumClose3, 13))    
if array.size(sumClose3) > 14
    array.push(get_index_values14, array.get(sumClose3, 14))
if array.size(sumClose3) > 15
    array.push(get_index_values15, array.get(sumClose3, 15))
if array.size(sumClose3) > 16
    array.push(get_index_values16, array.get(sumClose3, 16))
if array.size(sumClose3) > 17
    array.push(get_index_values17, array.get(sumClose3, 17))
if array.size(sumClose3) > 18
    array.push(get_index_values18, array.get(sumClose3, 18))
if array.size(sumClose3) > 19
    array.push(get_index_values19, array.get(sumClose3, 19))
if array.size(sumClose3) > 20
    array.push(get_index_values20, array.get(sumClose3, 20))
if array.size(sumClose3) > 21
    array.push(get_index_values21, array.get(sumClose3, 21))
if array.size(sumClose3) > 22
    array.push(get_index_values22, array.get(sumClose3, 22))
if array.size(sumClose3) > 23
    array.push(get_index_values23, array.get(sumClose3, 23))    
if array.size(sumClose3) > 24
    array.push(get_index_values24, array.get(sumClose3, 24))
if array.size(sumClose3) > 25
    array.push(get_index_values25, array.get(sumClose3, 25))
if array.size(sumClose3) > 26
    array.push(get_index_values26, array.get(sumClose3, 26))
if array.size(sumClose3) > 27
    array.push(get_index_values27, array.get(sumClose3, 27))
if array.size(sumClose3) > 28
    array.push(get_index_values28, array.get(sumClose3, 28))
if array.size(sumClose3) > 29
    array.push(get_index_values29, array.get(sumClose3, 29))
if array.size(sumClose3) > 30
    array.push(get_index_values30, array.get(sumClose3, 30))

//---sumClose4 array
if array.size(sumClose4) > 0
    array.push(get_index_values0, array.get(sumClose4, 0))
if array.size(sumClose4) > 1
    array.push(get_index_values1, array.get(sumClose4, 1))
if array.size(sumClose4) > 2
    array.push(get_index_values2, array.get(sumClose4, 2))
if array.size(sumClose4) > 3
    array.push(get_index_values3, array.get(sumClose4, 3))    
if array.size(sumClose4) > 4
    array.push(get_index_values4, array.get(sumClose4, 4))
if array.size(sumClose4) > 5
    array.push(get_index_values5, array.get(sumClose4, 5))
if array.size(sumClose4) > 6
    array.push(get_index_values6, array.get(sumClose4, 6))
if array.size(sumClose4) > 7
    array.push(get_index_values7, array.get(sumClose4, 7))
if array.size(sumClose4) > 8
    array.push(get_index_values8, array.get(sumClose4, 8))
if array.size(sumClose4) > 9
    array.push(get_index_values9, array.get(sumClose4, 9))
if array.size(sumClose4) > 10
    array.push(get_index_values10, array.get(sumClose4, 10))
if array.size(sumClose4) > 11
    array.push(get_index_values11, array.get(sumClose4, 11))
if array.size(sumClose4) > 12
    array.push(get_index_values12, array.get(sumClose4, 12))
if array.size(sumClose4) > 13
    array.push(get_index_values13, array.get(sumClose4, 13))    
if array.size(sumClose4) > 14
    array.push(get_index_values14, array.get(sumClose4, 14))
if array.size(sumClose4) > 15
    array.push(get_index_values15, array.get(sumClose4, 15))
if array.size(sumClose4) > 16
    array.push(get_index_values16, array.get(sumClose4, 16))
if array.size(sumClose4) > 17
    array.push(get_index_values17, array.get(sumClose4, 17))
if array.size(sumClose4) > 18
    array.push(get_index_values18, array.get(sumClose4, 18))
if array.size(sumClose4) > 19
    array.push(get_index_values19, array.get(sumClose4, 19))
if array.size(sumClose4) > 20
    array.push(get_index_values20, array.get(sumClose4, 20))
if array.size(sumClose4) > 21
    array.push(get_index_values21, array.get(sumClose4, 21))
if array.size(sumClose4) > 22
    array.push(get_index_values22, array.get(sumClose4, 22))
if array.size(sumClose4) > 23
    array.push(get_index_values23, array.get(sumClose4, 23))    
if array.size(sumClose4) > 24
    array.push(get_index_values24, array.get(sumClose4, 24))
if array.size(sumClose4) > 25
    array.push(get_index_values25, array.get(sumClose4, 25))
if array.size(sumClose4) > 26
    array.push(get_index_values26, array.get(sumClose4, 26))
if array.size(sumClose4) > 27
    array.push(get_index_values27, array.get(sumClose4, 27))
if array.size(sumClose4) > 28
    array.push(get_index_values28, array.get(sumClose4, 28))
if array.size(sumClose4) > 29
    array.push(get_index_values29, array.get(sumClose4, 29))
if array.size(sumClose4) > 30
    array.push(get_index_values30, array.get(sumClose4, 30))

//---sumClose5 array
if array.size(sumClose5) > 0
    array.push(get_index_values0, array.get(sumClose5, 0))
if array.size(sumClose5) > 1
    array.push(get_index_values1, array.get(sumClose5, 1))
if array.size(sumClose5) > 2
    array.push(get_index_values2, array.get(sumClose5, 2))
if array.size(sumClose5) > 3
    array.push(get_index_values3, array.get(sumClose5, 3))    
if array.size(sumClose5) > 4
    array.push(get_index_values4, array.get(sumClose5, 4))
if array.size(sumClose5) > 5
    array.push(get_index_values5, array.get(sumClose5, 5))
if array.size(sumClose5) > 6
    array.push(get_index_values6, array.get(sumClose5, 6))
if array.size(sumClose5) > 7
    array.push(get_index_values7, array.get(sumClose5, 7))
if array.size(sumClose5) > 8
    array.push(get_index_values8, array.get(sumClose5, 8))
if array.size(sumClose5) > 9
    array.push(get_index_values9, array.get(sumClose5, 9))
if array.size(sumClose5) > 10
    array.push(get_index_values10, array.get(sumClose5, 10))
if array.size(sumClose5) > 11
    array.push(get_index_values11, array.get(sumClose5, 11))
if array.size(sumClose5) > 12
    array.push(get_index_values12, array.get(sumClose5, 12))
if array.size(sumClose5) > 13
    array.push(get_index_values13, array.get(sumClose5, 13))    
if array.size(sumClose5) > 14
    array.push(get_index_values14, array.get(sumClose5, 14))
if array.size(sumClose5) > 15
    array.push(get_index_values15, array.get(sumClose5, 15))
if array.size(sumClose5) > 16
    array.push(get_index_values16, array.get(sumClose5, 16))
if array.size(sumClose5) > 17
    array.push(get_index_values17, array.get(sumClose5, 17))
if array.size(sumClose5) > 18
    array.push(get_index_values18, array.get(sumClose5, 18))
if array.size(sumClose5) > 19
    array.push(get_index_values19, array.get(sumClose5, 19))
if array.size(sumClose5) > 20
    array.push(get_index_values20, array.get(sumClose5, 20))
if array.size(sumClose5) > 21
    array.push(get_index_values21, array.get(sumClose5, 21))
if array.size(sumClose5) > 22
    array.push(get_index_values22, array.get(sumClose5, 22))
if array.size(sumClose5) > 23
    array.push(get_index_values23, array.get(sumClose5, 23))    
if array.size(sumClose5) > 24
    array.push(get_index_values24, array.get(sumClose5, 24))
if array.size(sumClose5) > 25
    array.push(get_index_values25, array.get(sumClose5, 25))
if array.size(sumClose5) > 26
    array.push(get_index_values26, array.get(sumClose5, 26))
if array.size(sumClose5) > 27
    array.push(get_index_values27, array.get(sumClose5, 27))
if array.size(sumClose5) > 28
    array.push(get_index_values28, array.get(sumClose5, 28))
if array.size(sumClose5) > 29
    array.push(get_index_values29, array.get(sumClose5, 29))
if array.size(sumClose5) > 30
    array.push(get_index_values30, array.get(sumClose5, 30))

//---sumClose6 array
if array.size(sumClose6) > 0
    array.push(get_index_values0, array.get(sumClose6, 0))
if array.size(sumClose6) > 1
    array.push(get_index_values1, array.get(sumClose6, 1))
if array.size(sumClose6) > 2
    array.push(get_index_values2, array.get(sumClose6, 2))
if array.size(sumClose6) > 3
    array.push(get_index_values3, array.get(sumClose6, 3))    
if array.size(sumClose6) > 4
    array.push(get_index_values4, array.get(sumClose6, 4))
if array.size(sumClose6) > 5
    array.push(get_index_values5, array.get(sumClose6, 5))
if array.size(sumClose6) > 6
    array.push(get_index_values6, array.get(sumClose6, 6))
if array.size(sumClose6) > 7
    array.push(get_index_values7, array.get(sumClose6, 7))
if array.size(sumClose6) > 8
    array.push(get_index_values8, array.get(sumClose6, 8))
if array.size(sumClose6) > 9
    array.push(get_index_values9, array.get(sumClose6, 9))
if array.size(sumClose6) > 10
    array.push(get_index_values10, array.get(sumClose6, 10))
if array.size(sumClose6) > 11
    array.push(get_index_values11, array.get(sumClose6, 11))
if array.size(sumClose6) > 12
    array.push(get_index_values12, array.get(sumClose6, 12))
if array.size(sumClose6) > 13
    array.push(get_index_values13, array.get(sumClose6, 13))    
if array.size(sumClose6) > 14
    array.push(get_index_values14, array.get(sumClose6, 14))
if array.size(sumClose6) > 15
    array.push(get_index_values15, array.get(sumClose6, 15))
if array.size(sumClose6) > 16
    array.push(get_index_values16, array.get(sumClose6, 16))
if array.size(sumClose6) > 17
    array.push(get_index_values17, array.get(sumClose6, 17))
if array.size(sumClose6) > 18
    array.push(get_index_values18, array.get(sumClose6, 18))
if array.size(sumClose6) > 19
    array.push(get_index_values19, array.get(sumClose6, 19))
if array.size(sumClose6) > 20
    array.push(get_index_values20, array.get(sumClose6, 20))
if array.size(sumClose6) > 21
    array.push(get_index_values21, array.get(sumClose6, 21))
if array.size(sumClose6) > 22
    array.push(get_index_values22, array.get(sumClose6, 22))
if array.size(sumClose6) > 23
    array.push(get_index_values23, array.get(sumClose6, 23))    
if array.size(sumClose6) > 24
    array.push(get_index_values24, array.get(sumClose6, 24))
if array.size(sumClose6) > 25
    array.push(get_index_values25, array.get(sumClose6, 25))
if array.size(sumClose6) > 26
    array.push(get_index_values26, array.get(sumClose6, 26))
if array.size(sumClose6) > 27
    array.push(get_index_values27, array.get(sumClose6, 27))
if array.size(sumClose6) > 28
    array.push(get_index_values28, array.get(sumClose6, 28))
if array.size(sumClose6) > 29
    array.push(get_index_values29, array.get(sumClose6, 29))
if array.size(sumClose6) > 30
    array.push(get_index_values30, array.get(sumClose6, 30))

//---sumClose7 array
if array.size(sumClose7) > 0
    array.push(get_index_values0, array.get(sumClose7, 0))
if array.size(sumClose7) > 1
    array.push(get_index_values1, array.get(sumClose7, 1))
if array.size(sumClose7) > 2
    array.push(get_index_values2, array.get(sumClose7, 2))
if array.size(sumClose7) > 3
    array.push(get_index_values3, array.get(sumClose7, 3))    
if array.size(sumClose7) > 4
    array.push(get_index_values4, array.get(sumClose7, 4))
if array.size(sumClose7) > 5
    array.push(get_index_values5, array.get(sumClose7, 5))
if array.size(sumClose7) > 6
    array.push(get_index_values6, array.get(sumClose7, 6))
if array.size(sumClose7) > 7
    array.push(get_index_values7, array.get(sumClose7, 7))
if array.size(sumClose7) > 8
    array.push(get_index_values8, array.get(sumClose7, 8))
if array.size(sumClose7) > 9
    array.push(get_index_values9, array.get(sumClose7, 9))
if array.size(sumClose7) > 10
    array.push(get_index_values10, array.get(sumClose7, 10))
if array.size(sumClose7) > 11
    array.push(get_index_values11, array.get(sumClose7, 11))
if array.size(sumClose7) > 12
    array.push(get_index_values12, array.get(sumClose7, 12))
if array.size(sumClose7) > 13
    array.push(get_index_values13, array.get(sumClose7, 13))    
if array.size(sumClose7) > 14
    array.push(get_index_values14, array.get(sumClose7, 14))
if array.size(sumClose7) > 15
    array.push(get_index_values15, array.get(sumClose7, 15))
if array.size(sumClose7) > 16
    array.push(get_index_values16, array.get(sumClose7, 16))
if array.size(sumClose7) > 17
    array.push(get_index_values17, array.get(sumClose7, 17))
if array.size(sumClose7) > 18
    array.push(get_index_values18, array.get(sumClose7, 18))
if array.size(sumClose7) > 19
    array.push(get_index_values19, array.get(sumClose7, 19))
if array.size(sumClose7) > 20
    array.push(get_index_values20, array.get(sumClose7, 20))
if array.size(sumClose7) > 21
    array.push(get_index_values21, array.get(sumClose7, 21))
if array.size(sumClose7) > 22
    array.push(get_index_values22, array.get(sumClose7, 22))
if array.size(sumClose7) > 23
    array.push(get_index_values23, array.get(sumClose7, 23))    
if array.size(sumClose7) > 24
    array.push(get_index_values24, array.get(sumClose7, 24))
if array.size(sumClose7) > 25
    array.push(get_index_values25, array.get(sumClose7, 25))
if array.size(sumClose7) > 26
    array.push(get_index_values26, array.get(sumClose7, 26))
if array.size(sumClose7) > 27
    array.push(get_index_values27, array.get(sumClose7, 27))
if array.size(sumClose7) > 28
    array.push(get_index_values28, array.get(sumClose7, 28))
if array.size(sumClose7) > 29
    array.push(get_index_values29, array.get(sumClose7, 29))
if array.size(sumClose7) > 30
    array.push(get_index_values30, array.get(sumClose7, 30))

//---sumClose8 array
if array.size(sumClose8) > 0
    array.push(get_index_values0, array.get(sumClose8, 0))
if array.size(sumClose8) > 1
    array.push(get_index_values1, array.get(sumClose8, 1))
if array.size(sumClose8) > 2
    array.push(get_index_values2, array.get(sumClose8, 2))
if array.size(sumClose8) > 3
    array.push(get_index_values3, array.get(sumClose8, 3))    
if array.size(sumClose8) > 4
    array.push(get_index_values4, array.get(sumClose8, 4))
if array.size(sumClose8) > 5
    array.push(get_index_values5, array.get(sumClose8, 5))
if array.size(sumClose8) > 6
    array.push(get_index_values6, array.get(sumClose8, 6))
if array.size(sumClose8) > 7
    array.push(get_index_values7, array.get(sumClose8, 7))
if array.size(sumClose8) > 8
    array.push(get_index_values8, array.get(sumClose8, 8))
if array.size(sumClose8) > 9
    array.push(get_index_values9, array.get(sumClose8, 9))
if array.size(sumClose8) > 10
    array.push(get_index_values10, array.get(sumClose8, 10))
if array.size(sumClose8) > 11
    array.push(get_index_values11, array.get(sumClose8, 11))
if array.size(sumClose8) > 12
    array.push(get_index_values12, array.get(sumClose8, 12))
if array.size(sumClose8) > 13
    array.push(get_index_values13, array.get(sumClose8, 13))    
if array.size(sumClose8) > 14
    array.push(get_index_values14, array.get(sumClose8, 14))
if array.size(sumClose8) > 15
    array.push(get_index_values15, array.get(sumClose8, 15))
if array.size(sumClose8) > 16
    array.push(get_index_values16, array.get(sumClose8, 16))
if array.size(sumClose8) > 17
    array.push(get_index_values17, array.get(sumClose8, 17))
if array.size(sumClose8) > 18
    array.push(get_index_values18, array.get(sumClose8, 18))
if array.size(sumClose8) > 19
    array.push(get_index_values19, array.get(sumClose8, 19))
if array.size(sumClose8) > 20
    array.push(get_index_values20, array.get(sumClose8, 20))
if array.size(sumClose8) > 21
    array.push(get_index_values21, array.get(sumClose8, 21))
if array.size(sumClose8) > 22
    array.push(get_index_values22, array.get(sumClose8, 22))
if array.size(sumClose8) > 23
    array.push(get_index_values23, array.get(sumClose8, 23))    
if array.size(sumClose8) > 24
    array.push(get_index_values24, array.get(sumClose8, 24))
if array.size(sumClose8) > 25
    array.push(get_index_values25, array.get(sumClose8, 25))
if array.size(sumClose8) > 26
    array.push(get_index_values26, array.get(sumClose8, 26))
if array.size(sumClose8) > 27
    array.push(get_index_values27, array.get(sumClose8, 27))
if array.size(sumClose8) > 28
    array.push(get_index_values28, array.get(sumClose8, 28))
if array.size(sumClose8) > 29
    array.push(get_index_values29, array.get(sumClose8, 29))
if array.size(sumClose8) > 30
    array.push(get_index_values30, array.get(sumClose8, 30))

//---sumClose9 array
if array.size(sumClose9) > 0
    array.push(get_index_values0, array.get(sumClose9, 0))
if array.size(sumClose9) > 1
    array.push(get_index_values1, array.get(sumClose9, 1))
if array.size(sumClose9) > 2
    array.push(get_index_values2, array.get(sumClose9, 2))
if array.size(sumClose9) > 3
    array.push(get_index_values3, array.get(sumClose9, 3))    
if array.size(sumClose9) > 4
    array.push(get_index_values4, array.get(sumClose9, 4))
if array.size(sumClose9) > 5
    array.push(get_index_values5, array.get(sumClose9, 5))
if array.size(sumClose9) > 6
    array.push(get_index_values6, array.get(sumClose9, 6))
if array.size(sumClose9) > 7
    array.push(get_index_values7, array.get(sumClose9, 7))
if array.size(sumClose9) > 8
    array.push(get_index_values8, array.get(sumClose9, 8))
if array.size(sumClose9) > 9
    array.push(get_index_values9, array.get(sumClose9, 9))
if array.size(sumClose9) > 10
    array.push(get_index_values10, array.get(sumClose9, 10))
if array.size(sumClose9) > 11
    array.push(get_index_values11, array.get(sumClose9, 11))
if array.size(sumClose9) > 12
    array.push(get_index_values12, array.get(sumClose9, 12))
if array.size(sumClose9) > 13
    array.push(get_index_values13, array.get(sumClose9, 13))    
if array.size(sumClose9) > 14
    array.push(get_index_values14, array.get(sumClose9, 14))
if array.size(sumClose9) > 15
    array.push(get_index_values15, array.get(sumClose9, 15))
if array.size(sumClose9) > 16
    array.push(get_index_values16, array.get(sumClose9, 16))
if array.size(sumClose9) > 17
    array.push(get_index_values17, array.get(sumClose9, 17))
if array.size(sumClose9) > 18
    array.push(get_index_values18, array.get(sumClose9, 18))
if array.size(sumClose9) > 19
    array.push(get_index_values19, array.get(sumClose9, 19))
if array.size(sumClose9) > 20
    array.push(get_index_values20, array.get(sumClose9, 20))
if array.size(sumClose9) > 21
    array.push(get_index_values21, array.get(sumClose9, 21))
if array.size(sumClose9) > 22
    array.push(get_index_values22, array.get(sumClose9, 22))
if array.size(sumClose9) > 23
    array.push(get_index_values23, array.get(sumClose9, 23))    
if array.size(sumClose9) > 24
    array.push(get_index_values24, array.get(sumClose9, 24))
if array.size(sumClose9) > 25
    array.push(get_index_values25, array.get(sumClose9, 25))
if array.size(sumClose9) > 26
    array.push(get_index_values26, array.get(sumClose9, 26))
if array.size(sumClose9) > 27
    array.push(get_index_values27, array.get(sumClose9, 27))
if array.size(sumClose9) > 28
    array.push(get_index_values28, array.get(sumClose9, 28))
if array.size(sumClose9) > 29
    array.push(get_index_values29, array.get(sumClose9, 29))
if array.size(sumClose9) > 30
    array.push(get_index_values30, array.get(sumClose9, 30))

//---sumClose10 array
if array.size(sumClose10) > 0
    array.push(get_index_values0, array.get(sumClose10, 0))
if array.size(sumClose10) > 1
    array.push(get_index_values1, array.get(sumClose10, 1))
if array.size(sumClose10) > 2
    array.push(get_index_values2, array.get(sumClose10, 2))
if array.size(sumClose10) > 3
    array.push(get_index_values3, array.get(sumClose10, 3))    
if array.size(sumClose10) > 4
    array.push(get_index_values4, array.get(sumClose10, 4))
if array.size(sumClose10) > 5
    array.push(get_index_values5, array.get(sumClose10, 5))
if array.size(sumClose10) > 6
    array.push(get_index_values6, array.get(sumClose10, 6))
if array.size(sumClose10) > 7
    array.push(get_index_values7, array.get(sumClose10, 7))
if array.size(sumClose10) > 8
    array.push(get_index_values8, array.get(sumClose10, 8))
if array.size(sumClose10) > 9
    array.push(get_index_values9, array.get(sumClose10, 9))
if array.size(sumClose10) > 10
    array.push(get_index_values10, array.get(sumClose10, 10))
if array.size(sumClose10) > 11
    array.push(get_index_values11, array.get(sumClose10, 11))
if array.size(sumClose10) > 12
    array.push(get_index_values12, array.get(sumClose10, 12))
if array.size(sumClose10) > 13
    array.push(get_index_values13, array.get(sumClose10, 13))    
if array.size(sumClose10) > 14
    array.push(get_index_values14, array.get(sumClose10, 14))
if array.size(sumClose10) > 15
    array.push(get_index_values15, array.get(sumClose10, 15))
if array.size(sumClose10) > 16
    array.push(get_index_values16, array.get(sumClose10, 16))
if array.size(sumClose10) > 17
    array.push(get_index_values17, array.get(sumClose10, 17))
if array.size(sumClose10) > 18
    array.push(get_index_values18, array.get(sumClose10, 18))
if array.size(sumClose10) > 19
    array.push(get_index_values19, array.get(sumClose10, 19))
if array.size(sumClose10) > 20
    array.push(get_index_values20, array.get(sumClose10, 20))
if array.size(sumClose10) > 21
    array.push(get_index_values21, array.get(sumClose10, 21))
if array.size(sumClose10) > 22
    array.push(get_index_values22, array.get(sumClose10, 22))
if array.size(sumClose10) > 23
    array.push(get_index_values23, array.get(sumClose10, 23))    
if array.size(sumClose10) > 24
    array.push(get_index_values24, array.get(sumClose10, 24))
if array.size(sumClose10) > 25
    array.push(get_index_values25, array.get(sumClose10, 25))
if array.size(sumClose10) > 26
    array.push(get_index_values26, array.get(sumClose10, 26))
if array.size(sumClose10) > 27
    array.push(get_index_values27, array.get(sumClose10, 27))
if array.size(sumClose10) > 28
    array.push(get_index_values28, array.get(sumClose10, 28))
if array.size(sumClose10) > 29
    array.push(get_index_values29, array.get(sumClose10, 29))
if array.size(sumClose10) > 30
    array.push(get_index_values30, array.get(sumClose10, 30))

//----summa summarium 

index_0_avg = array.avg(get_index_values0)
index_1_avg = array.avg(get_index_values1)
index_2_avg = array.avg(get_index_values2)
index_3_avg = array.avg(get_index_values3)
index_4_avg = array.avg(get_index_values4)
index_5_avg = array.avg(get_index_values5)
index_6_avg = array.avg(get_index_values6)
index_7_avg = array.avg(get_index_values7)
index_8_avg = array.avg(get_index_values8)
index_9_avg = array.avg(get_index_values9)
index_10_avg = array.avg(get_index_values10)
index_11_avg = array.avg(get_index_values11)
index_12_avg = array.avg(get_index_values12)
index_13_avg = array.avg(get_index_values13)
index_14_avg = array.avg(get_index_values14)
index_15_avg = array.avg(get_index_values15)
index_16_avg = array.avg(get_index_values16)
index_17_avg = array.avg(get_index_values17)
index_18_avg = array.avg(get_index_values18)
index_19_avg = array.avg(get_index_values19)
index_20_avg = array.avg(get_index_values20)
index_21_avg = array.avg(get_index_values21)
index_22_avg = array.avg(get_index_values22)
index_23_avg = array.avg(get_index_values23)
index_24_avg = array.avg(get_index_values24)
index_25_avg = array.avg(get_index_values25)
index_26_avg = array.avg(get_index_values26)
index_27_avg = array.avg(get_index_values27)
index_28_avg = array.avg(get_index_values28)
index_29_avg = array.avg(get_index_values29)
index_30_avg = array.avg(get_index_values30)



index_avg = array.from(index_0_avg, index_1_avg, index_2_avg, index_3_avg, index_4_avg, index_5_avg, index_6_avg, index_7_avg, index_8_avg, index_9_avg, index_10_avg, index_11_avg, index_12_avg, index_13_avg, index_14_avg, index_15_avg, index_16_avg, index_17_avg, index_18_avg, index_19_avg, index_20_avg, index_21_avg, index_22_avg, index_23_avg, index_24_avg, index_25_avg, index_26_avg, index_27_avg, index_28_avg, index_29_avg, index_30_avg)

//die durchschnitte der finalen Zusammenfassungen
avg_value = array.avg(index_avg)
size_avg = array.size(index_avg)


//calculate the tradingdays in the array
tradingdays = -1 
for j = 0 to size1
    tradingdays += 1

tradingDayOf_TimeRange = 0 
if startDateTime0 and ta.change(dayofmonth(time)) != 0
    tradingDayOf_TimeRange  += 1


//zusammenfassung der array durchscnittswerte 
sumClose = close-open

LongTermAVG = input(25)
r_avg_value = ta.sma(ma, LongTermAVG)

ShortTermAVG = input(1)
r_avg_value1 = ta.sma(ma, ShortTermAVG )


//bull and bear conditions 
bull_or_bear = r_avg_value > avg_value ? "BullL" : r_avg_value < avg_value ? "BearL" : "--"
bull_or_bear_color = r_avg_value > avg_value ? channel_upcolor : r_avg_value < avg_value ? channel_downcolor : 
  r_avg_value > array.max(index_avg) ? channel_upcolor_power : r_avg_value < array.min(index_avg) ? channel_downcolor : channel_neutralcolor

bull_or_bear1 = r_avg_value1 > avg_value ? "BullS" : r_avg_value1 < avg_value ? "BearS" : "--"
bull_or_bear_color1 = r_avg_value1 > avg_value ? channel_upcolor : r_avg_value1 < avg_value ? channel_downcolor : 
  r_avg_value1 > array.max(index_avg) ? channel_upcolor_power : r_avg_value1 < array.min(index_avg) ? channel_downcolor : channel_neutralcolor

//-----matrix size of spalten  
matrix_columns = 250
var m = matrix.new<float>(10, matrix_columns, 0)
var table table_ = na




if size1 > 0 
    str = ""
    for i = 0 to size1 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose1, i))
if size2 > 0 
    str = ""
    for i = 0 to size2 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose2, i))
if size3 > 0 
    str = ""
    for i = 0 to size3 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose3, i))
if size4 > 0 
    str = ""
    for i = 0 to size4 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose4, i))
if size5 > 0 
    str = ""
    for i = 0 to size5 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose5, i))
if size6 > 0 
    str = ""
    for i = 0 to size6 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose6, i))
if size7 > 0 
    str = ""
    for i = 0 to size7 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose7, i))
if size8 > 0 
    str = ""
    for i = 0 to size8 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose8, i))
if size9 > 0 
    str = ""
    for i = 0 to size9 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose9, i))
if size10 > 0 
    str = ""
    for i = 0 to size10 - 1
        str += str.tostring(i) + ": " + str.tostring(array.get(sumClose10, i))
if size_avg > 0 
    str = ""
    for i = 0 to size_avg - 1 
        str += str.tostring(i) + ": " + str.tostring(array.get(index_avg, i))



//----------------------------

var table = table.new(position = i_position, columns = 34, rows = 14, bgcolor = color.rgb(0, 0, 0), frame_color=color.rgb(87, 38, 38), frame_width = 1, border_color = color.rgb(61, 28, 28), border_width = 1)
if barstate.islast
    table.cell(table_id = table, column = 1, row = 0, text = "TDOM", text_font_family = font.family_monospace, text_color = color.silver, text_size = size.small)
    for i = 0 to size1 -1 
        table.cell(table_id = table, column = 2+i, row = 0, text = str.tostring(1+i), text_font_family = font.family_monospace, text_color = color.silver, text_size = size.small)
    for i = 0 to 9
        table.cell(table_id = table, column = 1, row = 1+i, text = str.tostring(1+i), text_font_family = font.family_monospace, text_color = color.silver, text_size = size.small)
    table.cell(table_id = table, column = 1, row = 11, text = "AVG", text_font_family = font.family_monospace, text_color = color.silver, text_size = size.small)
    table.cell(table_id = table, column = 1, row = 12, text = "AVGnow", text_font_family = font.family_monospace, text_color = color.silver, text_size = size.small)
    table.cell(table_id = table, column = 2, row = 13, text = "" + str.tostring(sumClose), text_font_family = font.family_monospace, text_color = color.silver, text_size = size.small, bgcolor = color.new(#414b70, 10))
    for i = 0 to size10 -1
        table.cell(table, 2+i, 1, str.tostring(array.get(sumClose10, i), "##.##") , bgcolor = color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size9 -1
        table.cell(table, 2+i, 2, str.tostring(array.get(sumClose9, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size8 -1
        table.cell(table, 2+i, 3, str.tostring(array.get(sumClose8, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size7 -1
        table.cell(table, 2+i, 4, str.tostring(array.get(sumClose7, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size6 -1
        table.cell(table, 2+i, 5, str.tostring(array.get(sumClose6, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size5 -1
        table.cell(table, 2+i, 6, str.tostring(array.get(sumClose5, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size4 -1
        table.cell(table, 2+i, 7, str.tostring(array.get(sumClose4, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size3 -1
        table.cell(table, 2+i, 8, str.tostring(array.get(sumClose3, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size2 -1
        table.cell(table, 2+i, 9, str.tostring(array.get(sumClose2, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)
    for i = 0 to size1 -1
        table.cell(table, 2+i, 10, str.tostring(array.get(sumClose1, i), "##.##") , bgcolor =  color.new(#222020, 10), text_color = color.white, text_size = size.small)    
    for i = 0 to size_avg - 1 
        table.cell(table, 2+i, 11, str.tostring(nz(array.get(index_avg , i)), "##.##") , bgcolor = color.new(#457041, 10), text_color = color.white, text_size = size.small) 
    for i = 0 to size0 - 1 
        table.cell(table, 2+i, 12, str.tostring(array.get(sumClose00, i), "##.##") , bgcolor = color.new(#414b70, 10), text_color = color.white, text_size = size.small)     
//"TradingPeriode from first to last >> "
    table.cell(table, 1, 13, text="Cons", text_color = color.white, text_size = size.small)     
    //"Open-Close Price Change >> "
    table.cell(table, 3, 13, text="Trend" , bgcolor = color.new(#414b70, 10), text_color = color.white, text_size = size.small)  
    //"Open-Close Avg. Change in % of Length LongTerm >> "
    table.cell(table, 4, 13, str.tostring(r_avg_value, "LT ##.##") , bgcolor = color.new(#414b70, 10), text_color = color.white, text_size = size.small)  
    //"Open-Close Avg. Change in % of Length ShortTerm >> "
    table.cell(table, 5, 13, str.tostring(r_avg_value1, "ST ##.##") , bgcolor = color.new(#414b70, 10), text_color = color.white, text_size = size.small)  
        //"This Year is over or under Avg of last 10 Year LongTerm >> "
    table.cell(table, 6, 13, str.tostring(bull_or_bear) , bgcolor =  color.new(#414b70, 10), text_color = bull_or_bear_color1, text_size = size.small)  
        //"This Year is over or under Avg of last 10 Year ShortTerm >> "
    table.cell(table, 7, 13, str.tostring(bull_or_bear1) , bgcolor = color.new(#414b70, 10), text_color = bull_or_bear_color1, text_size = size.small)  

            //"MAX
    table.cell(table, 9, 13, text="MAX", bgcolor =  color.new(#457041, 10), text_color = color.white, text_size = size.small)  
    table.cell(table, 10, 13, str.tostring(array.max(index_avg), "##.##") , bgcolor = color.new(#457041, 10), text_color = color.white, text_size = size.small)  
            //"MIN
    table.cell(table, 11, 13, text="MIN" , bgcolor =  color.new(#457041, 10), text_color = color.white, text_size = size.small)  
    table.cell(table, 12, 13, str.tostring(array.min(index_avg), "##.##") , bgcolor = color.new(#457041, 10), text_color = color.white, text_size = size.small)  
            //"AVG
    table.cell(table, 13, 13, text="AVG" , bgcolor =  color.new(#457041, 10), text_color = color.white, text_size = size.small)  
    table.cell(table, 14, 13, str.tostring(avg_value, "##.##") , bgcolor = color.new(#457041, 10), text_color = color.white, text_size = size.small)  

    table.cell(table, 16, 13, text="C.1/10", bgcolor = color.new(#723f35, 10), text_color = color.white, text_size = size.small)  
    table.cell(table, 17, 13, str.tostring(array.get(check, 0), "##.##") , bgcolor = color.new(#723f35, 10), text_color = color.white, text_size = size.small)   

max_0 = array.max(index_avg)
min_0 = array.min(index_avg)
avg_0 = avg_value


//barcolor 1 candle average is > or < than arrays average 
gradientl1 = color.from_gradient(r_avg_value1, avg_0, max_0, gradient_upcolor_weak_bar , gradient_upcolor_strong_bar)
gradients1 = color.from_gradient(r_avg_value1, min_0, avg_0, gradient_downcolor_strong_bar, gradient_downcolor_weak_bar)
gradient1 = r_avg_value1 > avg_0 ? gradientl1 : gradients1
barcolor(gradient1, title="Candle is > or < than arrays average")

//bull and bear conditions 
gradientl = color.from_gradient(r_avg_value, avg_0, max_0, gradient_upcolor_weak , gradient_upcolor_strong)
gradients = color.from_gradient(r_avg_value, min_0, avg_0, gradient_downcolor_strong, gradient_downcolor_weak)
gradient = r_avg_value > avg_0 ? gradientl : gradients


max_min_calculation_to_add_to_MidBand = input(5, title = "MIN & MAX Band", tooltip = "This will calculate the upper and lower Band. That means its added to the MidBand, which is an SMA of Close with the length of 21, to add the average Change of the time chosen Array")
max = ta.sma(close, max_min_calculation_to_add_to_MidBand) * (1 + max_0 / 100)
min = ta.sma(close, max_min_calculation_to_add_to_MidBand ) * (1 + min_0 / 100)
 
band = input(21, title = "MIN; MAX; MID Band Length")
min_band = ta.sma(min, band)
mid_band =  ta.sma(close, band)
max_band = ta.sma(max, band)
channel_8 = ta.sma(low, 8)
channel_10 = ta.sma(high, 10)

channel_col = channel_8 > mid_band ? color.rgb(11, 82, 139, 80) : channel_10 < mid_band ?  color.rgb(136, 20, 123, 80) :  color.rgb(81, 77, 81, 70)

plot(min_band, color=gradient, linewidth = 2, title = "MIN AVG - Lower Band")
plot(mid_band, color=gradient, linewidth = 2, title = "AVG - Mid Band")
plot(max_band, color=gradient, linewidth = 2, title = "MAX AVG - Upper Band")
p6 = plot(channel_8, color=channel_col, title = "SMA 8 low Band")
p7 = plot(channel_10, color=channel_col, title = "SMA 10 high Band")
fill(p7, p6, channel_col, title = "Channel Color Filling", display = display.none)

month_begin = ta.change(month)
bgcolor(month_begin ? color.rgb(120, 123, 134, 91) : na, display = display.none) 