Advertisement
xmd79

RSI Signals

Oct 18th, 2023
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © TrungChuThanh
  3.  
  4. //@version=4
  5. study("RSI Signals", overlay=true, shorttitle="TPG.Buy sell RSI Scapl XAU")
  6.  
  7. //Inputs
  8. rsiL = input(title="RSI Length", type=input.integer, defval=7)
  9. rsiOBI = input(title="RSI Overbought", type=input.integer, defval=70)
  10. rsiOSI = input(title="RSI Oversold", type=input.integer, defval=30)
  11. fibLevel = input(title="Hammer Body Size", type=input.float, defval=0.333, step=0.01)
  12. BullBearEngulf = input(title="Bullish Bearish Engulfing", type=input.bool, defval=true)
  13. hammerShooting = input(title="Hammer Shooting Bar", type=input.bool, defval=false)
  14. twoBullBearBar = input(title="Two Bull Bear Bar", type=input.bool, defval=false)
  15.  
  16. //RSI VALUE
  17. myRsi = rsi(close , rsiL)
  18.  
  19. //RSI OVERBOUGHT / OVERSOLD
  20. rsiOB = myRsi >= rsiOBI
  21. rsiOS = myRsi <= rsiOSI
  22.  
  23. ///////////=Hammer & Shooting star=/////////////
  24.  
  25. bullFib = (low - high) * fibLevel + high
  26. bearFib = (high - low) * fibLevel + low
  27.  
  28. // Determine which price source closses or open highest/lowest
  29. bearCandle = close < open ? close : open
  30. bullCandle = close > open ? close : open
  31.  
  32. // Determine if we have a valid hammer or shooting star
  33. hammer = (bearCandle >= bullFib) and rsiOS
  34. shooting = (bullCandle <= bearFib) and rsiOB
  35.  
  36. twoGreenBars = (close > open and close[1] > open[1]) and rsiOS
  37. twoRedBars = (close < open and close[1] < open[1]) and rsiOB
  38.  
  39. /////////////////////////////////////////////
  40.  
  41. // Engulfing candles
  42. bullE = (close > open[1] and close[1] < open[1])
  43. //or hammer or twoGreenBars
  44.  
  45. bearE = close < open[1] and close[1] > open[1]
  46. //or shooting or twoRedBars
  47.  
  48. ///////////////////////////////////////////
  49.  
  50. // ((x) y) farmula defination is: X is gona be executed before Y,
  51. TradeSignal = ((rsiOS or rsiOS[1]) and bullE) or ((rsiOB or rsiOB[1]) and bearE)
  52.  
  53. if (TradeSignal and bearE and BullBearEngulf)
  54. label.new(x= bar_index, y= na, text="Sell", yloc= yloc.abovebar,color= color.maroon, textcolor= color.white, style= label.style_label_down, size=size.normal)
  55. plotshape(TradeSignal and bearE and BullBearEngulf, title="Overbought", location=location.abovebar, color=color.orange, style=shape.triangleup, size=size.auto, text="")
  56.  
  57. if (TradeSignal and bullE and BullBearEngulf)
  58. label.new(x= bar_index, y= na, text="Buy", yloc= yloc.belowbar,color= color.green, textcolor= color.white, style= label.style_label_up, size=size.normal)
  59. plotshape(TradeSignal and bullE and BullBearEngulf, title="Oversold", location=location.belowbar, color=color.lime, style=shape.triangleup, size=size.auto, text="")
  60.  
  61. //////////////////////////////
  62.  
  63. if (shooting and hammerShooting)
  64. label.new(x= bar_index, y= na, text="SS", yloc= yloc.abovebar,color= color.purple, textcolor= color.white, style= label.style_label_down, size=size.normal)
  65. plotshape(shooting and hammerShooting, title="Overbought + hammer/shooting", location=location.abovebar, color=color.purple, style=shape.triangledown, size=size.auto, text="")
  66.  
  67. if (hammer and hammerShooting)
  68. label.new(x= bar_index, y= na, text="HMR", yloc= yloc.belowbar,color= color.blue, textcolor= color.white, style= label.style_label_up, size=size.normal)
  69. plotshape(hammer and hammerShooting, title="Oversold + hammer/shooting", location=location.belowbar, color=color.lime, style=shape.triangledown, size=size.auto, text="")
  70.  
  71. ///////////////////////////
  72.  
  73. if (twoGreenBars and twoBullBearBar)
  74. label.new(x= bar_index, y= na, text="2Bull", yloc= yloc.belowbar,color= color.olive, textcolor= color.white, style= label.style_label_up, size=size.normal)
  75. plotshape(twoGreenBars and twoBullBearBar, title="Oversold + 2bulls", location=location.belowbar, color=color.lime, style=shape.triangledown, size=size.auto, text="")
  76.  
  77. if (twoRedBars and twoBullBearBar)
  78. label.new(x= bar_index, y= na, text="2Bear", yloc= yloc.abovebar,color= color.red, textcolor= color.white, style= label.style_label_down, size=size.normal)
  79. plotshape(twoRedBars and twoBullBearBar, title="Overbought + 2bears", location=location.abovebar, color=color.blue, style=shape.triangledown, size=size.auto, text="")
  80.  
  81. // Send Alert if Candle meets our condition
  82. alertcondition(TradeSignal, title="RSI SIGNAL", message="RSI Signal Detected fot {{ticker}}")
  83.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement