OmegaDelta
// 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='OmegaDelta', shorttitle='ΩΔ')

string display = input.string(defval='absolute', options=['absolute', 'relative'])

var float[] trajectories = array.new_float(1, 0.0)
float difference = close - open
float alpha = (1.0 / bar_index) * difference
for _i = 0 to array.size(trajectories)-1
    float _y = array.get(trajectories, _i) * alpha
    array.set(trajectories, _i, _y)

array.unshift(trajectories, difference)

float od = switch (display)
    ('absolute') => array.sum(trajectories)
    ('relative') => array.sum(trajectories) / close

plot(series=od, title='ΩΔ', color=color.blue)
hline(0)