Advertisement
xmd79

Rob RSI StochMACD Combo Alert

Jan 14th, 2023
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. //@version=2
  2.  
  3. //Created by Robert Nance on 5/28/16. Additional credit to vdubus.
  4. //This was a special request from rich15stan. It combines my original RSI Stoch extremes with vdubus’ MACD VXI.
  5. //This script will give you red or green columns as an indication for oversold/overbought,
  6. //based upon the rsi and stochastic both being at certain levels. The default oversold is at 35.
  7. //If Stochastic and RSI fall below 35, you will get a green column. Play with your levels to see how
  8. //your stock reacts. It now adds the MACD crossover, plotted as a blue circle.
  9.  
  10. study(title="Rob RSI StochMACD Combo Alert", shorttitle="Rob RSI StochMACD")
  11.  
  12. src = input(close), len = input(14, minval=1, title="RSI Length")
  13. up = rma(max(change(src), 0), len)
  14. down = rma(-min(change(src), 0), len)
  15. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
  16.  
  17. length = input(14, minval=1, title="Stoch Length"), smoothK = input(1, minval=1, title="Stoch K")
  18. k = sma(stoch(src, high, low, length), smoothK)
  19.  
  20. rsilow = input(35, title="rsi Low value")
  21. rsihigh = input(65, title="rsi High value")
  22. stochlow = input(35, title="stochastic Low value")
  23. stochhigh = input(65, title="stochastic High value")
  24. Buy=rsi<rsilow and k<stochlow
  25. Sell=rsi>rsihigh and k>stochhigh
  26.  
  27. fastLength = input(13, minval=1,title="MACD Fast Length")
  28. slowLength = input(21,minval=1,title="MACD Slow Length")
  29. signalLength = input(8,minval=1,title="MACD Signal Length")
  30. fastMA = ema(src, fastLength)
  31. slowMA = ema(src, slowLength)
  32. macd = fastMA - slowMA
  33. signal = sma(macd, signalLength)
  34.  
  35. plot(Buy, title= "Buy", style=columns, color=lime)
  36. plot(Sell, title= "Sell", style=columns, color=red)
  37. plot(cross(signal, macd) ? signal*0+.5 : na, color=blue, style = circles, linewidth = 4)
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement