Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator(title='Compound Sine Waves for Market Reversals', precision=12)
- // Input parameters for sine waves
- base_wave_height = input(100, title='Base Wave Height')
- base_wave_duration = input(161, title='Base Wave Duration')
- harmonic_wave_height = input(50, title='Harmonic Wave Height')
- harmonic_wave_duration = input(54, title='Harmonic Wave Duration')
- extra_harmonic_wave_height = input(25, title='Extra Harmonic Height')
- extra_harmonic_wave_duration = input(27, title='Extra Harmonic Duration')
- n = bar_index
- // Function to generate sine waves
- f_sine_wave(_wave_height, _wave_duration) =>
- _pi = 3.14159265359
- _w = 2 * _pi / _wave_duration
- _sine_wave = _wave_height * math.sin(_w * n)
- _sine_wave
- // Calculate sine waves
- base_sine_wave = f_sine_wave(base_wave_height, base_wave_duration)
- harmonic_sine_wave = f_sine_wave(harmonic_wave_height, harmonic_wave_duration)
- extra_harmonic_sine_wave = f_sine_wave(extra_harmonic_wave_height, extra_harmonic_wave_duration)
- // Combined sine wave
- compound_sine_wave = base_sine_wave + harmonic_sine_wave + extra_harmonic_sine_wave
- // Detect crossover and crossunder for potential reversal points
- min_trigger = ta.crossover(base_sine_wave, compound_sine_wave)
- max_trigger = ta.crossunder(base_sine_wave, compound_sine_wave)
- // Plotting the sine waves and triggers
- plot(series=base_sine_wave, title='Base Sine Wave', color=color.green)
- plot(series=harmonic_sine_wave, title='Harmonic Sine Wave', color=color.red)
- plot(series=extra_harmonic_sine_wave, title='Extra Harmonic Wave', color=color.blue)
- plot(series=compound_sine_wave, title='Compound Sine Wave', color=color.purple)
- // Plotting the reversal signals
- plotshape(series=min_trigger, title='Min Trigger', style=shape.triangledown, location=location.absolute, color=color.black, size=size.small)
- plotshape(series=max_trigger, title='Max Trigger', style=shape.triangleup, location=location.absolute, color=color.white, size=size.small)
- // Displaying market sentiment based on the sine wave pattern
- bgcolor(close > compound_sine_wave ? color.new(color.green, 90) : na)
- bgcolor(close < compound_sine_wave ? color.new(color.red, 90) : na)
- // Alert conditions for potential reversals
- alertcondition(min_trigger, title='Min Trigger Alert', message='Potential Market Bottom Detected!')
- alertcondition(max_trigger, title='Max Trigger Alert', message='Potential Market Top Detected!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement