Advertisement
xmd79

2sines decomposition

Oct 31st, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. //@version=5
  2. indicator(title='2-Sine Wave Decomposition', precision=12)
  3.  
  4. wave_height = input(100)
  5. wave_duration1 = input(161)
  6. wave_duration2 = input(217)
  7. wave_phase1 = input(0)
  8. wave_phase2 = input(0)
  9.  
  10. n = bar_index
  11.  
  12. f_sine_wave(_wave_height, _wave_duration, _wave_phase) =>
  13. _pi = 3.14159265359
  14. _w = 2 * _pi / _wave_duration
  15. _sine_wave = _wave_height * math.sin(_w * n + _wave_phase)
  16. _sine_wave
  17.  
  18. sine_wave1 = f_sine_wave(wave_height, wave_duration1, wave_phase1)
  19. sine_wave2 = f_sine_wave(wave_height, wave_duration2, wave_phase2)
  20.  
  21. min_trigger = ta.crossover(sine_wave1, sine_wave2)
  22. max_trigger = ta.crossunder(sine_wave1, sine_wave2)
  23.  
  24. plot(series=sine_wave1, title='Sine Wave 1', color=color.green)
  25. plot(series=sine_wave2, title='Sine Wave 2', color=color.red)
  26. plot(series=min_trigger ? sine_wave1 : na, title='Min Trigger', style=plot.style_cross, linewidth=3, color=color.black)
  27. plot(series=max_trigger ? sine_wave1 : na, title='Max Trigger', style=plot.style_cross, linewidth=3, color=color.blue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement