Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("Stationary Triple Wave", overlay=false)
- // Define input parameters
- len1 = input.int(5, "Length 1")
- len2 = input.int(10, "Length 2")
- len3 = input.int(20, "Length 3")
- // Calculate the waves
- wave1 = math.sin(2 * math.pi * len1 / bar_index)
- wave2 = math.sin(2 * math.pi * len2 / bar_index)
- wave3 = math.sin(2 * math.pi * len3 / bar_index)
- // Combine the waves using polarization
- polarization = input("Linear", "Polarization")
- var wave = 0.0
- if polarization == "Linear"
- wave := wave1 + wave2 + wave3
- else
- var phase = bar_index * math.pi / len3
- wave := wave1 * math.cos(phase) + wave2 * math.sin(phase) + wave3 * math.cos(2 * phase)
- // Add close price to the wave
- wave += input(close)
- // Stationary filter smoother
- length = input.int(10, "Smoother Length")
- smoother = 0.0
- for i = 0 to length - 1
- smoother += wave[i]
- smoother /= length
- // Plot the smoothed wave
- plot(smoother, color=color.red)
Advertisement
Add Comment
Please, Sign In to add comment