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

//@version=5
indicator("Botvenko Script", shorttitle="BS", precision=4)
nn = input(60, "Histogram Period")
candles = input(60, "Candle Dominance Сhart Period")
float x = 0
float z = 0
float k = 0



y = math.log(close[0]) - math.log(close[nn])
if y>0
    x := y
else
    k := y
    

counter_of_candles(kk) => 
    float total = 0
    int cutter = 10
    while kk/10>10
        cutter*=10
    for i = 0 to kk
        if close[i] - close[i+1] > 0
            total += 1
        else
            total -= 1
    total/cutter
        
        


plot(y > 0 ? x: 0, color = color.green, linewidth = 4)
plot(y <= 0 ? k: 0, color = color.maroon, linewidth = 4)
plot(y, color = color.yellow, linewidth = 1, style = plot.style_histogram)
plot(counter_of_candles(candles), color = color.navy, linewidth = 3)



hline(0, title='zero', color=color.white, linestyle=hline.style_dotted, linewidth=2)
