Advertisement
Guest User

IDDQD-alpha

a guest
Sep 30th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  1. //╔════════════════════════════════════════════════════════════════════════════╗
  2. //║ ║
  3. //║ ▓▓ ▓▓ ▓▓▓▓▓ ▓▓ ▓▓ ║
  4. //║ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓▓ ▓▓▓ ▓▓ ║
  5. //║ ▓▓ ▓ ▓▓ ▓▓▓▓▓ ▓▓ ▓ ▓▓ ▓▓▓▓▓▓ ║
  6. //║ ▓▓▓▓▓▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ║
  7. //║ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ▓▓ ║
  8. //║ ║
  9. //║ < WT_RSI_MFI+ > ║
  10. //╟──────────────┬─────────────────────────────────────────────────────────────╢
  11. //║ Description: │ An indicator conglomerate combining Wavetrend from LB, ║
  12. //║ │ RSI and MFI with buy and sell signals ║
  13. //╟──────────────┼─────────────────────────────────────────────────────────────╢
  14. //║ Authors: │ liHard, Lazybear for Wavetrend ║
  15. //╟──────────────┼─────────────────────────────────────────────────────────────╢
  16. //║ Version: │ 0.20 2014_09_13 ║
  17. //╚══════════════╧═════════════════════════════════════════════════════════════╝
  18.  
  19. study(title="IDDQD-α", shorttitle="IDDQD-α")
  20.  
  21. alt_symb = input(title="Symbol", type=symbol, defval="BTCE:BTCUSD")
  22. set_symbol = input(false, "Set symbol")
  23. close_src = set_symbol ? security(alt_symb, period, close) : close
  24. hlc3_src = set_symbol ? security(alt_symb, period, hlc3) : hlc3
  25.  
  26. //---------------------------------------------------------------------
  27. //--- Wavetrend -------------------------------------------------------
  28. wt_n1 = input(10, "WT Channel Length")
  29. wt_n2 = input(21, "WT Average Length")
  30. wt_ob_lev1 = input(60, "WT Overbought Level 1")
  31. wt_ob_lev2 = input(53, "WT Overbought Level 2")
  32. wt_os_lev1 = input(-70, "WT Oversold Level 1")
  33. wt_os_lev2 = input(-53, "WT Oversold Level 2")
  34. wt_ap = hlc3_src
  35. wt_esa = ema(wt_ap, wt_n1)
  36. wt_d = ema(abs(wt_ap - wt_esa), wt_n1)
  37. wt_ci = (wt_ap - wt_esa) / (0.015 * wt_d)
  38. wt_tci = ema(wt_ci, wt_n2)
  39. wt1 = wt_tci
  40. wt2 = sma(wt1,4)
  41.  
  42. //---------------------------------------------------------------------
  43. //--- RSI -------------------------------------------------------------
  44. rsi_length = input(title="RSI length", type=integer, defval=14, minval=1, maxval=2000)
  45. rsi_ob_lev = input(70, "RSI overbought level")
  46. rsi_os_lev = input(30, "RSI oversold level")
  47. rsi = rsi(close_src, rsi_length)
  48.  
  49. //---------------------------------------------------------------------
  50. //--- MFI -------------------------------------------------------------
  51. mfi_length = input(title="MFI length", type=integer, defval=14, minval=1, maxval=2000)
  52. mfi_ob_lev = input(80, "MFI overbought level")
  53. mfi_os_lev = input(20, "MFI oversold level")
  54. mfi_src = hlc3_src
  55. mfi_upper = sum(volume * (change(mfi_src) <= 0 ? 0 : mfi_src), mfi_length)
  56. mfi_lower = sum(volume * (change(mfi_src) >= 0 ? 0 : mfi_src), mfi_length)
  57. mfi = rsi(mfi_upper, mfi_lower)
  58.  
  59. //---------------------------------------------------------------------
  60. //--- buy/sell signals ------------------------------------------------
  61. wt_cor = (wt1+100)*0.5
  62.  
  63. //---------------------------------------------------------------------
  64. //--- ob/os calc 0 ----------------------------------------------------
  65. rsi_win = input(3, "RSI window length", minval=1)
  66. mfi_win = input(3, "MFI window length", minval=1)
  67. wt_win = input(3, "WT window length", minval=1)
  68. wt_overbought = highest(wt1, wt_win) > wt_ob_lev1 ? 1 : 0
  69. wt_oversold = lowest(wt1, wt_win) < wt_os_lev1 ? 1 : 0
  70. mfi_overbought = highest(mfi, mfi_win) > mfi_ob_lev ? 1 : 0
  71. mfi_oversold = lowest(mfi, mfi_win) < mfi_os_lev ? 1 : 0
  72. rsi_overbought = highest(rsi, rsi_win) > rsi_ob_lev ? 1 : 0
  73. rsi_oversold = lowest(rsi, rsi_win) < rsi_os_lev ? 1 : 0
  74. //rsi_over_lev = rsi_overbought == 1 ? rsi_ob_lev : rsi_oversold == 1 ? rsi_os_lev : na
  75.  
  76. overbought_0 = rsi_overbought + mfi_overbought + wt_overbought >= 3
  77. oversold_0 = rsi_oversold + mfi_oversold + wt_oversold >= 3
  78. stupid_bgcolor_0 = overbought_0 ? #FF0000 : oversold_0 ? #00FF00 : #000000
  79.  
  80. over_lev = overbought_0 ? 45 : oversold_0 ? 55 : na
  81.  
  82. //---------------------------------------------------------------------
  83. //--- plot ------------------------------------------------------------
  84. //plotshape(over_lev, "ob_os", shape.circle, location.absolute, stupid_bgcolor_0, 50, 0)
  85. plot(over_lev, color=stupid_bgcolor_0, style=linebr, linewidth=4)
  86.  
  87. mfi_ob_line = hline(mfi_ob_lev, title="MFI overbought", color=#804040)
  88. rsi_ob_line = hline(rsi_ob_lev, title="RSI overbought", color=#808080)
  89. hline(50, color=#606060)
  90. rsi_os_line = hline(rsi_os_lev, title="RSI oversold", color=#808080)
  91. mfi_os_line = hline(mfi_os_lev, title="MFI oversold", color=#408040)
  92. fill(rsi_ob_line, rsi_os_line, color=#404080, transp=70)
  93.  
  94. plot(wt_cor, title="WT", color=#006080, style=line)
  95. plot(mfi, title="MFI", color=#308010, style=line)
  96. plot(rsi, title="RSI", color=#FFFFFF, style=line, linewidth=1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement