xmd79

Stationary Triple Wave filtered

Apr 7th, 2023
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. //@version=5
  2. indicator("Stationary Triple Wave", overlay=false)
  3.  
  4. // Define input parameters
  5. len1 = input.int(5, "Length 1")
  6. len2 = input.int(10, "Length 2")
  7. len3 = input.int(20, "Length 3")
  8.  
  9. // Calculate the waves
  10. wave1 = math.sin(2 * math.pi * len1 / bar_index)
  11. wave2 = math.sin(2 * math.pi * len2 / bar_index)
  12. wave3 = math.sin(2 * math.pi * len3 / bar_index)
  13.  
  14. // Combine the waves using polarization
  15. polarization = input("Linear", "Polarization")
  16. var wave = 0.0
  17. if polarization == "Linear"
  18. wave := wave1 + wave2 + wave3
  19. else
  20. var phase = bar_index * math.pi / len3
  21. wave := wave1 * math.cos(phase) + wave2 * math.sin(phase) + wave3 * math.cos(2 * phase)
  22.  
  23. // Add close price to the wave
  24. wave += input(close)
  25.  
  26. // Stationary filter smoother
  27. length = input.int(10, "Smoother Length")
  28. smoother = 0.0
  29. for i = 0 to length - 1
  30. smoother += wave[i]
  31. smoother /= length
  32.  
  33. // Plot the smoothed wave
  34. plot(smoother, color=color.red)
Advertisement
Add Comment
Please, Sign In to add comment