Advertisement
JustUncleL

Fractal Resonance Component R3

Dec 25th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. //@version=2
  2.  
  3. //
  4. // @author LazyBear
  5. // If you use this code in its original/modified form, do drop me a note.
  6. //
  7. // Revisions:
  8. // R1: Original - LazyBear.
  9. // R2: by pythagoras
  10. // - Added Time scaling factor.
  11. // - Colored Overbought and oversold zones.
  12. // - Added extreme OS and OB indication (cross)
  13. // - Plus other changes
  14. // R3: by JustUncleL
  15. // - Added inner levels for wtdiff analysis
  16. // - Added highlighting of wtdiff crossing into centre channel
  17. //
  18. //
  19. study(title="Fractal Resonance Component R3 revised by JustUncleL", shorttitle="FR_COMPONENT R3")
  20.  
  21. stratMultiplier = input(defval = 1, title = "Timescale Multiplier")
  22.  
  23. n1 = input(19, "Channel Length")
  24. n2 = input(17, "Stochastic Ratio Filter")
  25. crossover_sma_len = input(11, "Crossover Lag (>1)")
  26.  
  27. obLevel = input(75, "Overbought %")
  28. osLevel = -obLevel
  29. obExtremeLevel = input(100, "Extreme Overbought %")
  30. osExtremeLevel = -obExtremeLevel
  31.  
  32. // === R3
  33. obinnerLevel = input(20, "Inner Level %")
  34. osinnerLevel = -obinnerLevel
  35. // === /R3
  36.  
  37. waveTrend( ap, n_channel, n_average, timeMultiplier ) =>
  38. esa = ema(ap, n_channel*timeMultiplier)
  39. d = ema(abs(ap - esa), n_channel*timeMultiplier)
  40. ci = 100*(ap - esa) / d
  41. tci = ema(ci, n_average*timeMultiplier)
  42. wtA= tci
  43. wtB = sma(wtA,crossover_sma_len*timeMultiplier)
  44. wtDiff = wtA-wtB
  45. [wtA, wtB, wtDiff]
  46.  
  47. [wta, wtb, wtdiff] = waveTrend( hlc3 , n1, n2, stratMultiplier )
  48. obE = hline(obExtremeLevel, color=white, linestyle=dashed, linewidth=1)
  49. ob = hline(obLevel, color=white, linestyle=dotted, linewidth=1)
  50. fill(ob, obE, color=maroon, transp=90)
  51. os = hline(osLevel, color=white, linestyle=dotted, linewidth=1)
  52. osE = hline(osExtremeLevel, color=white, linestyle=dashed, linewidth=1)
  53. fill(os, osE, color=olive, transp=90)
  54.  
  55. // === R3
  56. obi = hline(obinnerLevel, color=black, linestyle=line, linewidth=1)
  57. osi = hline(osinnerLevel, color=black, linestyle=line, linewidth=1)
  58. plot(crossunder(wtdiff, obinnerLevel) ? wtdiff : na, color = red , style = circles, linewidth = 4)
  59. plot(crossover(wtdiff, osinnerLevel) ? wtdiff : na, color = green , style = circles, linewidth = 4)
  60. // === /R3
  61.  
  62. plot(wtdiff, color=blue, style=area, transp=80)
  63. plot( wta, color=green)
  64. plot( wtb, color=red)
  65. extreme_cross = (wta > obExtremeLevel or wta < osExtremeLevel) and cross(wta, wtb)
  66. significant_cross = (wta > obLevel or wta < osLevel) and cross(wta, wtb)
  67. plot(significant_cross ? wta : na, color = black , style = circles, linewidth = 3)
  68. plot(extreme_cross ? wta : na, color = black , style = cross, linewidth = 3)
  69. cross_circle_color = (wtb - wta > 0) ? red : lime
  70. //cross_circle_color = at_extremes ? (wtb - wta > 0 ? red : lime) : (wtb - wta > 0 ? #FF9900 : aqua)
  71. plot(cross(wta, wtb) ? wtb : na, color = cross_circle_color , style = circles, linewidth = 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement