xmd79

Inverse Chebyshev Filter

Jun 1st, 2023
192
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. //@version=5
  2. indicator("Inverse Chebyshev Filter", overlay=false)
  3.  
  4. // Input parameters
  5. length = input(10, "Length")
  6. order = input(3, "Order")
  7.  
  8. // Function to calculate inverse Chebyshev
  9. invChebyshev(src, len, ord) =>
  10. a = math.pow(2 / (len + 1), 2)
  11. b = 2 * math.cos(ord * math.acos(-1) / len)
  12. c1 = (1 - math.sqrt(math.abs(1 - math.pow(b, 2)))) / b
  13. c2 = (1 - math.sqrt(math.abs(1 - math.pow(b, 2)))) / a
  14. c3 = -1 * c1
  15. c4 = -2 * c2
  16. res = 0.0
  17. res := c1 * src + c2 * nz(src[1]) + c3 * nz(res[1]) + c4 * nz(res[2])
  18. res
  19.  
  20. // Calculate inverse Chebyshev
  21. invCheby = invChebyshev(close, length, order)
  22.  
  23. // Plotting
  24. plot(invCheby, color=color.rgb(181, 115, 228), title="Inverse Chebyshev")
Advertisement
Comments
Add Comment
Please, Sign In to add comment