Sinusoidal High Pass Filter  (SHPF)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262

//@version=5
indicator("Sinusoidal High Pass Filter")
sinusoidal_hpf(_series, _period, _phase_shift) =>
    ma = 0.0
    for i = 0 to _period - 1
        weight = math.sin(i * 2 * math.pi / _period + _phase_shift * math.pi / 180)
        ma := ma + weight * _series[i]
    ma / _period

source = input.source(close, "Source")
length = input.int(10, "Length", 1)
shift  = input.float(90, "Phase Shift", 0, 360, 0.5)

plot(0, "0", color.silver)
plot(sinusoidal_hpf(source, length, shift), "Sinusoidal High Pass Filter", color.new(color.purple, 10))
