munkeefonix

BTC Historic indicator for tradingview.com

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