Advertisement
xmd79

PIP HUNTERSCR STOCH RSI SIGNALL with Alert

Jan 24th, 2023 (edited)
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. //@version=5
  2. //Created by Morreno on SEPTEMBER 28, 2019 For PIPHUNTER MOVEMENT.
  3. //Update to version 5 by keRLos
  4. indicator(title="PIP HUNTERSCR STOCH RSI SIGNALL with Alert", shorttitle="PIP HUNTERSCR STOCH RSI SIGNAL with Alert")
  5. len = input.int(10,"Longitud Estocastico", 1)
  6. smoothK = input.int(3, minval=1, title="%K Stoch")
  7. smoothD = input.int(3, minval=1, title="%D Stoch")
  8. upLine = input.int(90, minval=55, maxval=95, title="Higher band")
  9. lowLine = input.int(10, minval=5, maxval=45, title="Lower Band")
  10. sml = input(true, title="Show mid line?")
  11. sbh = input(true, title="Show Back Ground Highlights When RSI is Above/Below High/Low Lines?")
  12. sch = input(true, title="Show Back Ground Highlights When RSI Cross? - strict criteria - line K - higher/lower high/low - Cross D ?")
  13. sac = input(false, title="Show Back Ground Highlights When RSI Cross?")
  14. useCurrentRes = input(true, title="Use Current Chart Resolution?")
  15. resCustom = input.timeframe(title="Use Different Timeframe? Uncheck Box Above", defval="60")
  16. //Resolution for Multiple time frames
  17. res = useCurrentRes ? timeframe.period : resCustom
  18. //var new
  19. h1 = upLine
  20. h2 = lowLine
  21.  
  22. inp = input(close)
  23.  
  24. //Stoch formula
  25. k = ta.sma(ta.stoch(inp, high, low, len), smoothK)
  26. d = ta.sma(k, smoothD)
  27. outK = request.security(syminfo.tickerid, res, k)
  28. outD = request.security(syminfo.tickerid, res, d)
  29. //definitions for Cross
  30. aboveLine = outK > upLine ? 1 : 0
  31. belowLine = outK < lowLine ? 1 : 0
  32. crossUp = (outK[1] < outD[1] and outK[1] < lowLine[1]) and (outK > outD) ? 1 : 0
  33. crossDn = (outK[1] > outD[1] and outK[1] > upLine[1]) and (outK < outD) ? 1 : 0
  34. //Definition for Cross that doesn't have to be above or below High and Low line.
  35. crossUpAll = (outK[1] < outD[1] and outK > outD) ? 1 : 0
  36. crossDownAll = (outK[1] > outD[1] and outK < outD) ? 1 : 0
  37. //BackGroound Color Plots
  38. bgcolor(sbh and aboveLine ? color.new(#FF5252,90) : na)
  39. bgcolor(sbh and belowLine ? color.new(#4CAF50,90) : na)
  40. bgcolor(sch and crossUp ? color.new(#4CAF50,40) : na)
  41. bgcolor(sch and crossDn ? color.new(#FF5252,40) : na)
  42.  
  43. alertcondition(crossUp, 'Crossup', 'Oversold')
  44. alertcondition(crossDn, 'Crossdown', 'Overbought')
  45.  
  46. //plots for Cross with no filter
  47. bgcolor(sac and crossUpAll ? color.new(#4CAF50,40) : na)
  48. bgcolor(sac and crossDownAll ? color.new(#FF5252,40) : na)
  49. //Plot main Stochastic
  50. plot(outK, title="Stoch K", linewidth=1, color=color.green)
  51. plot(outD, title="Stoch D", linewidth=1, color=color.red)
  52. //plot(upLine, title= "Banda mayor", style=dashed, linewidth=1, color=#FF5252)
  53. //plot(lowLine, title= "Banda menor", style=dashed, linewidth=1, color=#4CAF50)
  54. hline(h1, color=#FF5252, editable=true, linestyle=hline.style_dashed)
  55. hline(h2, color=#4CAF50, editable=true, linestyle=hline.style_dashed)
  56. hline(50, color=color.gray, editable=true, linestyle=hline.style_dashed)
  57. //plot(sml and 50 ? 50 : na, title="Linea Medio", style=dashed, linewidth=1, color=gray)
  58. //fill(p1, p2, color=silver, transp=70)
  59.  
  60. //rsi formula
  61. src = inp
  62. rlen = input.int(14, minval=1, title="RSI Length")
  63. chg = ta.change(src)
  64. up = ta.rma(ta.max(chg), rlen)
  65. down = ta.rma(-ta.min(chg), rlen)
  66. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
  67. //Plot secundary rsi
  68. plot(rsi, title='Enable RSI Band',color=#0000ff, linewidth=1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement