Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator("EMA + RSI + ML Strategy with Harmonic Waves", overlay=false)
- // Inputs for EMA
- length200 = 200
- lengthEMA1 = 5
- // Calculate EMAs with the 'ta' namespace
- ema200 = ta.ema(close, length200)
- ema1 = ta.ema(close, lengthEMA1)
- // Simple Buy and Sell Conditions for Testing
- buyCondition = close > ema200 and close > ema1
- sellCondition = close < ema200 and close < ema1
- // Enhanced Signal Visualization
- buySignal = buyCondition ? low : na // Buy signal
- sellSignal = sellCondition ? high : na // Sell signal
- // Plot shapes for buy and sell signals
- plotshape(series=buySignal, location=location.belowbar, color=color.blue, style=shape.diamond, size=size.small, title="Buy Signal")
- plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.diamond, size=size.small, title="Sell Signal")
- // Alerts
- alertcondition(buyCondition, title="Buy Condition", message="Buy condition met.")
- alertcondition(sellCondition, title="Sell Condition", message="Sell condition met.")
- // Sinusoidal harmonic wave parameters
- waveFrequency = 2.0 // Frequency of the wave
- waveAmplitude = 5.0 // Amplitude of the wave
- wavePhaseShift = 0 // Adjust phase shift if necessary
- // Calculate the harmonic wave
- harmonicWave = waveAmplitude * math.sin((bar_index * waveFrequency * math.pi) / 180 + wavePhaseShift)
- // Plot the harmonic wave
- plot(harmonicWave, color=color.new(color.green, 0), title="Harmonic Wave", linewidth=2)
- // Polarity Shift: Define reversal zones based on EMA and harmonic wave
- reversalCondition = (close < ema200 and close < harmonicWave) or (close > ema200 and close > harmonicWave)
- // Plot signaling for potential reversals
- plotshape(reversalCondition, location=location.absolute, color=color.new(color.orange, 50), style=shape.triangledown, size=size.small, title="Potential Reversal Signal")
- // Alerts for polarity shifts/reversals
- alertcondition(reversalCondition, title="Reversal Condition", message="Potential reversal condition met.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement