xmd79

rsi channelbands

May 5th, 2023
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. // © brettkind
  2. //@version=4
  3. study(title="rsi channelbands", shorttitle="RSI", overlay=false, format=format.percent, precision=1)//_____.RSI-Input.__________
  4. source = input(close, title="source")
  5. rsi = input(14, title="relative strength index", minval=1)
  6. chnl = input(20, title="Channelbands-length", minval=1)
  7. hl7030 = input(true, title="Horizontal Lines")
  8. THL = input(70, title="Top H-Line", minval=0, maxval=100, tooltip="Top > Mid > Low")
  9. MHL = input(50, title="Mid H-Line", minval=0, maxval=100, tooltip="Top > Mid > Low")
  10. LHL = input(30, title="Low H-Line", minval=0, maxval=100, tooltip="Top > Mid > Low")
  11. pivot = input(true, title="Pivot Channel")
  12. dnchn = input(true, title="Donchian Channel")
  13. boll = input(true, title="Bollinger Bands")
  14. avgfktr = (hl7030?1:0) + (dnchn?1:0) + (boll?1:0) + (pivot?1:0)
  15. //_____.RSI-Source.__________
  16. rsicls = rsi(source,rsi)
  17. //_____.RSI-Pivot.__________
  18. rsihigh = pivothigh(rsicls,chnl/2,chnl/2)
  19. rsilow = pivotlow(rsicls,chnl/2,chnl/2)
  20. rsibshi = barssince(0<rsihigh)
  21. rsibslo = barssince(0<rsilow)
  22. rsihipl = rsihigh[rsibshi]
  23. rsilopl = rsilow[rsibslo]
  24. rsifrpv = avg(rsihipl,rsilopl)
  25. //_____.RSI-Bollinger.__________
  26. [rsibfr, rsibupp, rsiblow] = bb(rsicls, chnl, 1)
  27. //_____.RSI-Donchian.__________
  28. rsidhiB = highest(rsicls, chnl)==rsicls
  29. rsidloB = lowest(rsicls, chnl)==rsicls
  30. rsidhi = highest(rsicls, chnl)
  31. rsidlo = lowest(rsicls, chnl)
  32. rsidfr = avg(rsidhi,rsidlo)
  33. //_____.RSI-Output.__________
  34. rsiovbuy = ( (pivot?rsihipl:0) + (boll?rsibupp:0) + (dnchn?rsidhi:0) + (hl7030?THL:0) ) / avgfktr
  35. rsifrprc = ( (pivot?rsifrpv:0) + (boll?rsibfr:0) + (dnchn?rsidfr:0) + (hl7030?MHL:0) ) / avgfktr
  36. rsiovsel = ( (pivot?rsilopl:0) + (boll?rsiblow:0) + (dnchn?rsidlo:0) + (hl7030?LHL:0) ) / avgfktr
  37. //_____.RSI-Plots.__________
  38. plot(rsiovbuy, color=color.new(color.gray,50), title="Overbought Line")
  39. plot(rsifrprc, color=avgfktr==1 and hl7030?color.gray:barssince(rsifrprc>rsifrprc[1])<barssince(rsifrprc<rsifrprc[1])?color.yellow:color.blue, title="Mid-Channel Line")
  40. plot(rsiovsel, color=color.new(color.gray,50), title="Oversold Line")
  41. CU=crossunder(rsicls,rsiovbuy)
  42. CO=crossover(rsicls,rsiovsel)
  43. plot(rsicls, color=color.white, title="relative strength index")
Add Comment
Please, Sign In to add comment