xmd79

RSI Candles [cI8DH]

Sep 20th, 2021
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. //@version=4
  2. //@author=cI8DH
  3. //original code by cI8:DH, I've just added hull moving average
  4. study("RSI Candles [cI8DH]", shorttitle="RSIC [cI8DH]", precision=0)
  5.  
  6. std = input(false, title="Show Standard RSI")
  7. candles = input(true, title="Show Candles")
  8. src = input(close, title="Source")
  9. len = input(14, minval=1, title="Length")
  10. hmalength = input(144, title="hull MA length")
  11. inner = input("Disable", title="Inner Band", options=["Dynamic", "Fixed", "Disable"])
  12. inner_type = input("Standard Deviation", options=["Standard Deviation", "Smoothed Moving Average"], title="Dynamic inner band calculation method")
  13. inner_mult = input(1.0, minval=0.0, step=0.2, title="Inner band width (Sideways band)")
  14. norm = if std
  15. 1
  16. else
  17. avg(src,src[1])
  18. gain_loss = change(src)/norm
  19. RSI = 50+50*rma(gain_loss, len)/rma(abs(gain_loss), len)
  20. RSI_ch = if inner!="Disable"
  21. if inner_type=="Standard Deviation"
  22. stdev(abs(change(RSI)), len)
  23. else
  24. rma(abs(change(RSI)), len)
  25.  
  26. plotcandle(candles?RSI[1]:na, candles?RSI:na, candles?RSI[1]:na, candles?RSI:na, title='RSI', color = src > src[1] ? #65D25Bff : #FE6B69ff, wickcolor=#88888800)
  27. plot(candles ? na : RSI, color=#a64d79ff, title="RSI")
  28. os = input(30,title="OverSold")
  29. ob= input(70,title="Overbought")
  30. fill(hline(os),hline(ob),color=#a64d7922, title="RSI Band")
  31. inner_high = plot(inner=="Disable" ? na : 50+inner_mult*(inner=="Dynamic" ? RSI_ch : 5.0), color=#a64d7933, title="Inner High")
  32. inner_low = plot(inner=="Disable" ? na : 50-inner_mult*(inner=="Dynamic" ? RSI_ch : 5.0), color=#a64d7933, title="Inner Low")
  33. fill(inner_high, inner_low, color=#a64d7922)
  34. hullma = wma(2*wma(RSI, hmalength/2)-wma(RSI, hmalength), floor(sqrt(hmalength)))
  35. plot(hullma, color= hullma > RSI ? color.orange : color.blue)
  36.  
  37. // plot(RSI, color=purple,title="RSI")
Advertisement
Add Comment
Please, Sign In to add comment