//@version=6 indicator(title="Dynamic Volume Levels (Plot+Labels) v6 Fixed", shorttitle="DVL Plot v6 (ідикатор пр свічках)", overlay=true, max_lines_count=500, max_labels_count=500) // --- Вхідні дані --- i_lookback = input.int(100, title="Lookback Period (Bars)", minval=10) i_num_candles = input.int(5, title="Number of Highest Volume Candles", minval=1) // *** Змінюємо maxval, щоб відповідати кількості plot() нижче *** i_levels_to_show = input.int(3, title="Number of S/R Levels to Show (Max 3)", minval=1, maxval=3) i_price_source = input.source(close, "Price Source for Levels") i_level_color_sup = input.color(color.green, title="Support Level Color") i_level_color_res = input.color(color.red, title="Resistance Level Color") i_label_color_sup = input.color(color.new(color.green, 10), title="Support Label BgColor") i_label_color_res = input.color(color.new(color.red, 10), title="Resistance Label BgColor") i_label_text_color = input.color(color.white, title="Label Text Color") // --- Логіка Збору Даних (залишається як раніше) --- var volume_array = array.new(0) var price_array = array.new(0) var bool data_ready = false volume_array.unshift(volume) price_array.unshift(i_price_source) while volume_array.size() > i_lookback volume_array.pop() price_array.pop() if not data_ready and volume_array.size() >= i_lookback data_ready := true var level_prices = array.new(0) if data_ready volume_copy = volume_array.copy() sorted_indices_desc = volume_copy.sort_indices(order.descending) level_prices.clear() for i = 0 to math.min(i_num_candles, sorted_indices_desc.size()) - 1 original_index = sorted_indices_desc.get(i) if original_index < price_array.size() price_level = price_array.get(original_index) is_unique = true for existing_level in level_prices if math.abs(price_level - existing_level) < syminfo.mintick * 2 is_unique := false break if is_unique array.push(level_prices, price_level) // --- Розділення та Сортування (залишається як раніше) --- var support_levels = array.new(0) var resistance_levels = array.new(0) support_levels.clear() resistance_levels.clear() current_price = close for level in level_prices if level < current_price array.push(support_levels, level) else if level > current_price array.push(resistance_levels, level) if support_levels.size() > 1 support_levels.sort(order.descending) if resistance_levels.size() > 1 resistance_levels.sort(order.ascending) // --- Візуалізація Міток та Рівнів через Plot --- // Масиви для ID міток var support_labels = array.new