Search for consolidations - AstroHub
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © AstroHub
 
//@version=5
indicator("Search for consolidations", overlay=true)

// Входные параметры
consol_length = input(20, "consolidation")

// Математическая модель для поиска консолидаций
isConsolidation(high, low, length) =>
    range1 = high - low
    avg_range = ta.sma(range1, length)
    consolidation = ta.sma(ta.rma(avg_range, length), length)

    range1 < consolidation

// Расчет результатов
consolidation = isConsolidation(high, low, consol_length)

// Отображение на графике
plotshape(consolidation, "Консолидация", color=color.blue, style=shape.labelup, location=location.belowbar)
