Advertisement
munkeefonix

BTC Historic Ichimoku Cloud

May 15th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. study("BTC Historic Ichimoku", overlay=true)
  2.  
  3. // author: munkeefonix
  4. // https://www.tradingview.com/u/munkeefonix/
  5. //
  6. // pastebin:
  7. // http://pastebin.com/ezrbb49D
  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. iCon=input(9, "Conversion", integer, minval=1)
  82. iTurn=input(26, "Turn", integer, minval=1)
  83. iLag=input(52, "Lag", integer, minval=1)
  84. iOff=input(26, "Displacement", integer, minval=1)
  85.  
  86. ichiCon=(highest(h, iCon)+lowest(l, iCon)) / 2
  87. ichiBase=(highest(h, iTurn)+lowest(l, iTurn)) / 2
  88. senkouA=(ichiCon+ichiBase)/2
  89. senkouB=(highest(h, iLag)+lowest(l, iLag)) / 2
  90.  
  91. plot(ichiCon, color=red, linewidth=1, title="Conversion Line")
  92. plot(ichiBase, color=purple, linewidth=1, title="Base Line")
  93. plot(c, color=yellow, linewidth=1, offset=-iOff, title="Lagging Span")
  94. sA = plot(senkouA, color=#999999, offset=iOff, title="Leading Span A", linewidth=1)
  95. sB = plot(senkouB, color=#999999, offset=iOff, title="Leading Span B", linewidth=2)
  96. fill(sA, sB, color=black, transp=90, title="Leading Fill Color")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement