test - wave collapse
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos

//@version=5
indicator(title='test - wave collapse')

// gaussian peak at (lx, ly)/2
g (x, y, lx, ly, z)=>
    math.exp(-0.5 * math.pow(x-lx/2.0, 2.0) - 0.5 * math.pow(y-ly/2.0, 2.0)) * (1.0/z)

length = input(100)
hb = math.abs(ta.highestbars(length)*0.1)
mhb = ta.cum(hb) / (bar_index + 1)
lb = math.abs(ta.lowestbars(length)*0.1)
mlb = ta.cum(lb) / (bar_index + 1)

plot(nz(-g(hb, hb, mhb, mhb, hb), 0.0))
plot(nz(g(lb, lb, mlb, mlb, lb), 0.0))
plot(nz(g(hb, lb, mhb, mlb, hb-lb), 0.0), '', color.yellow)
