Jurik Velocity ("smoother moment") [Loxx]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © loxx

//@version=5
indicator("Jurik Velocity (\"smoother moment\") [Loxx]", shorttitle="JV [Loxx]", timeframe="", overlay = false, timeframe_gaps=true)

greencolor = #2DD204  
redcolor = #D2042D 
//mom
_jurik_vol(src, len)=>
    suma = 0.0, sumb = 0.0, sumwa = 0.0, sumwb = 0.0
    for k = 0 to len by 1
        weight = len - k 
        suma  += src[k] * weight
        sumb  += src[k] * weight * weight
        sumwa += weight
        sumwb += weight * weight
    out = sumb/sumwb - suma/sumwa
    out 
    
src = input.source(close, "Source")
len = input.int(25, "Length")
colorbars = input.bool(false, "Color bars?")

out = _jurik_vol(src, len)

plot(out, color = out >= 0 ? greencolor : redcolor, linewidth = 2)

plot(0, color=color.new(color.gray, 30), linewidth=1, style=plot.style_circles, title = "Zero line")

barcolor(colorbars ? out > 0 ? greencolor : redcolor : na)