Advertisement
munkeefonix

BTC Historic RSI

May 15th, 2014
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. study("BTC Historic RSI", overlay=false)
  2.  
  3. // indicator created by: debani
  4. // https://www.tradingview.com/u/debani/
  5. //
  6. // pastebin:
  7. // http://pastebin.com/bJthxhXn
  8. //
  9. // more info about the indicator here:
  10. // https://www.tradingview.com/v/h2lfl0gT/
  11. //
  12. // notes:
  13. // Click the "eye" button next to the primary security to hide it.
  14. // Set the indicator scale is set to "Right".
  15. // Right click on the right axis, and uncheck "Scale Series Only"
  16. //
  17. // This inicator will have issues on subdaily and daily charts.
  18. // Should be used on weekly and monthly charts
  19. //
  20. // updated May-15-2014
  21. //
  22. // gox data
  23. goxH=security("MTGOX:BTCUSD",period,high)
  24. goxL=security("MTGOX:BTCUSD",period,low)
  25. goxC=security("MTGOX:BTCUSD",period,close)
  26.  
  27. stampH=security("BITSTAMP:BTCUSD",period,high)
  28. stampL=security("BITSTAMP:BTCUSD",period,low)
  29. stampC=security("BITSTAMP:BTCUSD",period,close)
  30.  
  31. goxWeight = input(title="Gox Weight", type=float, defval=80, minval=0.001, maxval=100)
  32. stampWeight = input(title="Stamp Weight", type=float, defval=20, minval=0.001, maxval=100)
  33. totalWeight = goxWeight + stampWeight
  34.  
  35. // the time to start transitioning from gox to 100% stamp.
  36. // 1377 is Jan-6-2014
  37. // 1385 is Jan-15-2014 (default)
  38. // 1337 is about the ATH (coincidentally)
  39. // 1192 is July-5-2013
  40.  
  41. // value of the current day.
  42. day=max(time/(86400 * 1000) - 14700, 0)
  43.  
  44. // debug: plot the day value on the chart.
  45. //plot(day)
  46.  
  47. endStart = input(title="Gox Taper Start Day", type=integer, defval=1385, minval=700, maxval=1405) * 1.0
  48. endTime = 1407.0
  49. otherBegin = 694.0
  50.  
  51. ratio=max(min((day-endStart)/(endTime-endStart), 1), 0)
  52. invRatio=1-ratio
  53.  
  54. goxRatio=invRatio * (goxWeight / totalWeight)
  55. otherRatio=(stampWeight / totalWeight) + ratio * (goxWeight/totalWeight)
  56.  
  57. // debug: display the ratios on the chart.
  58. //plot(goxRatio, color=yellow)
  59. //plot(otherRatio, color=green)
  60.  
  61. // debug: show the range of weights on the primary ticker bar.
  62. //barcolor(ratio == 0 ? red : (ratio == 1 ? yellow : blue))
  63.  
  64. // debug: show range of data of stamp data used (before: red, mixed: blue, all: yellow)
  65. //barcolor(day < otherBegin ? red : (day > endTime ? yellow : blue))
  66.  
  67. h = day < otherBegin ? goxH : (day > endTime ? stampH : (goxH * goxRatio + stampH * otherRatio))
  68. l = day < otherBegin ? goxL : (day > endTime ? stampL : (goxL * goxRatio + stampL * otherRatio))
  69. c = day < otherBegin ? goxC : (day > endTime ? stampC : (goxC * goxRatio + stampC * otherRatio))
  70.  
  71. //-----------------------------------------------------
  72. // custom indicators below
  73. // Since this going to be overlayed onto a symbol that will likely use weekdays
  74. // daily indicators will need to be adjusted to run a little faster.
  75. // fullWeekRatio: 5/7 = 0.714285
  76. // currently this cannot be done since multiplying the input values converts the value from an int to a series.
  77. //
  78. //adjustIndicator=isdwm and not isdaily
  79. //da=adjustIndicator ? 0.714285 : 1.0
  80.  
  81. src = c
  82. len = input(14, minval=1, title="Length")
  83. up = ema(max(change(src), 0), len)
  84. down = ema(-min(change(src), 0), len)
  85. rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
  86.  
  87. plot(rsi, color=purple)
  88. band1 = hline(70)
  89. band0 = hline(30)
  90. fill(band1, band0, color=purple, transp=90)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement