Averager
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © gnutovv

//@version=5
indicator("Averager", overlay = true, max_lines_count = 3, max_labels_count = 2)
//m_price = input.int(10000, minval = 10, title = "Balance")
period = input.int(45, minval=10, title="Period")
ma_fast = input.int(3, minval=1, title = "MA fast")
ma_slow = input.int(8, minval=3, title = "MA slow")
high_line = ta.highest(period)
low_line = ta.lowest(period)
divider = (high_line - low_line) / 6
in_divider = divider / 5
line_2 = low_line + divider
line_3 = low_line + divider * 2
line_4 = low_line + divider * 3
line_5 = low_line + divider * 4
line_6 = low_line + divider * 5
first_index = last_bar_index - period
first_analize_index = first_index + 1
last_index = last_bar_index + 3

// start_analyze_box
line.new(first_analize_index, high_line, first_analize_index, low_line, color = color.gray)
line.new(first_analize_index, high_line, last_index, high_line, color = color.gray)
line.new(first_analize_index, low_line, last_index, low_line, color = color.gray)

// MA
fast_ma_ind = ta.sma(close, ma_fast)
slow_ma_ind = ta.sma(close, ma_slow)

// Channel lines
line.new(first_analize_index, line_2, last_index, line_2, color=color.blue)
line.new(first_analize_index, line_3, last_index, line_3, color=color.green)
line.new(first_analize_index, line_4, last_index, line_4, color=color.yellow)
line.new(first_analize_index, line_5, last_index, line_5, color=color.orange)
line.new(first_analize_index, line_6, last_index, line_6, color=color.red)

// lables
label.new(last_index, low_line, '5; '+str.tostring(math.round(low_line, 4)), color=color.purple)
label.new(last_index, line_2, '4; '+str.tostring(math.round(line_2, 4)), color=color.blue)
label.new(last_index, line_3, '3; '+str.tostring(math.round(line_3, 4)), color=color.green)
label.new(last_index, line_4, '2; '+str.tostring(math.round(line_4, 4)), color=color.yellow)
label.new(last_index, line_5, '1; '+str.tostring(math.round(line_5, 4)), color=color.orange)
label.new(last_index, line_6, '0; '+str.tostring(math.round(line_6, 4)), color=color.red)

// icons
plotchar(fast_ma_ind > slow_ma_ind, 'plotchar', '🟢', location.belowbar, color.green, size = size.tiny, show_last = period)
plotchar(fast_ma_ind < slow_ma_ind, 'plotchar', '❌', location.belowbar, color.red, size = size.tiny, show_last = period)