Advertisement
xmd79

EMA + RSI + ML Strategy with Harmonic Waves

Nov 3rd, 2024
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. //@version=5
  2. indicator("EMA + RSI + ML Strategy with Harmonic Waves", overlay=false)
  3.  
  4. // Inputs for EMA
  5. length200 = 200
  6. lengthEMA1 = 5
  7.  
  8. // Calculate EMAs with the 'ta' namespace
  9. ema200 = ta.ema(close, length200)
  10. ema1 = ta.ema(close, lengthEMA1)
  11.  
  12. // Simple Buy and Sell Conditions for Testing
  13. buyCondition = close > ema200 and close > ema1
  14. sellCondition = close < ema200 and close < ema1
  15.  
  16. // Enhanced Signal Visualization
  17. buySignal = buyCondition ? low : na // Buy signal
  18. sellSignal = sellCondition ? high : na // Sell signal
  19.  
  20. // Plot shapes for buy and sell signals
  21. plotshape(series=buySignal, location=location.belowbar, color=color.blue, style=shape.diamond, size=size.small, title="Buy Signal")
  22. plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.diamond, size=size.small, title="Sell Signal")
  23.  
  24. // Alerts
  25. alertcondition(buyCondition, title="Buy Condition", message="Buy condition met.")
  26. alertcondition(sellCondition, title="Sell Condition", message="Sell condition met.")
  27.  
  28. // Sinusoidal harmonic wave parameters
  29. waveFrequency = 2.0 // Frequency of the wave
  30. waveAmplitude = 5.0 // Amplitude of the wave
  31. wavePhaseShift = 0 // Adjust phase shift if necessary
  32.  
  33. // Calculate the harmonic wave
  34. harmonicWave = waveAmplitude * math.sin((bar_index * waveFrequency * math.pi) / 180 + wavePhaseShift)
  35.  
  36. // Plot the harmonic wave
  37. plot(harmonicWave, color=color.new(color.green, 0), title="Harmonic Wave", linewidth=2)
  38.  
  39. // Polarity Shift: Define reversal zones based on EMA and harmonic wave
  40. reversalCondition = (close < ema200 and close < harmonicWave) or (close > ema200 and close > harmonicWave)
  41.  
  42. // Plot signaling for potential reversals
  43. plotshape(reversalCondition, location=location.absolute, color=color.new(color.orange, 50), style=shape.triangledown, size=size.small, title="Potential Reversal Signal")
  44.  
  45. // Alerts for polarity shifts/reversals
  46. alertcondition(reversalCondition, title="Reversal Condition", message="Potential reversal condition met.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement