Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=4
- study(title='Function Sine Wave')
- wave_height = input(100)
- wave_duration = input(50)
- f_sine_wave_1(_wave_height, _wave_duration) =>
- _pi = 3.14159265359
- _w = 2 * _pi / _wave_duration
- _sine_wave = _wave_height * sin(_w * bar_index)
- _sine_wave
- f_sine_wave_2(_wave_height, _wave_duration) =>
- _pi = 3.14159265359
- _w = 2 * _pi / _wave_duration
- _sine_wave = _wave_height * sin(_w * bar_index)
- _sine_wave
- wave = f_sine_wave_1(wave_height, wave_duration)
- wave2 = f_sine_wave_2(wave_height, close)
- plot(series=wave, title='Normal', color=color.black)
- plot(series=wave2, title='Price as cycle duration', color=color.red)
- //end of this part
- length = input(50)
- src = wave
- //----
- sum=0.,sumw=0.
- for i = 1 to length
- w = sin(2*3.14*i/length)/i
- sumw := sumw + w
- sum := sum + w*src[i-1]
- //----
- plot(sum/sumw,"Plot",#ff1100,2,transp=0)
Advertisement
Add Comment
Please, Sign In to add comment