Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Inverse Chebyshev Filter", overlay=false)
- // Input parameters
- length = input(10, "Length")
- order = input(3, "Order")
- // Function to calculate inverse Chebyshev
- invChebyshev(src, len, ord) =>
- a = math.pow(2 / (len + 1), 2)
- b = 2 * math.cos(ord * math.acos(-1) / len)
- c1 = (1 - math.sqrt(math.abs(1 - math.pow(b, 2)))) / b
- c2 = (1 - math.sqrt(math.abs(1 - math.pow(b, 2)))) / a
- c3 = -1 * c1
- c4 = -2 * c2
- res = 0.0
- res := c1 * src + c2 * nz(src[1]) + c3 * nz(res[1]) + c4 * nz(res[2])
- res
- // Calculate inverse Chebyshev
- invCheby = invChebyshev(close, length, order)
- // Plotting
- plot(invCheby, color=color.rgb(181, 115, 228), title="Inverse Chebyshev")
Advertisement