xmd79

[MAD MBS] Almost RSI

Oct 25th, 2022
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. //@version=5
  2. indicator('[MAD MBS] Almost RSI', shorttitle='[MAD MBS] Almost RSI', format=format.price, precision=2)
  3.  
  4.  
  5. ////////////////
  6. // Waves
  7. n1 = input.int(10, 'RSI Length')
  8. obLevel1 = input.float(3.5, 'Over Bought Level')
  9. osLevel1 = input.float(-3.5, 'Over Sold Level')
  10. TF = input.timeframe('15', title='Timeframe 1')
  11.  
  12. ////////// GET AND MAP ALL DATA ////////////////
  13.  
  14.  
  15. hline(-0, title='Middle Level', linestyle=hline.style_dotted, color=#606060)
  16.  
  17. f_rsi(_src, _n1) =>
  18. rsi = ta.rsi(_src, _n1)
  19. rsi
  20.  
  21.  
  22. rsi_TF1 = request.security(syminfo.tickerid, TF,f_rsi(close, n1), barmerge.gaps_on, barmerge.lookahead_off)
  23.  
  24. plot(0, color=color.new(#808080, 0))
  25.  
  26.  
  27. POWFACTOR = input(1.0,"POW",group="final averaging", tooltip='0 < compress < 1 < expand < 10')
  28. rsi_mtf = (rsi_TF1 -50) > 0 ? math.pow(rsi_TF1 -50,POWFACTOR) : - math.pow(math.abs(rsi_TF1 -50),POWFACTOR)
  29. rsi_mtf_average = ta.ema(ta.sma(rsi_mtf, input(20, 'sma',group="final averaging",inline='1a')), input(5, 'ema',group="final averaging",inline='1a', tooltip='disabled on \"1\"'))
  30.  
  31. triggersignal_use_avg = input(false, 'trigger on average',group="final averaging")
  32.  
  33. rsi_work = triggersignal_use_avg ? rsi_mtf_average : rsi_mtf
  34.  
  35. trl = plot(rsi_work, 'Triggerline', color=color.new(color.yellow, 0))
  36.  
  37. ////////////////
  38. osl = plot(osLevel1, 'Oversell-Line', color=color.gray)
  39. obl = plot(obLevel1, 'Overbuy-Line', color=color.gray)
  40.  
  41. fill(osl, trl, color=(rsi_work) < osLevel1 ? color.new(color.green, 40) : na)
  42. fill(obl, trl, color=(rsi_work) > obLevel1 ? color.new(color.red, 40) : na)
  43.  
  44. var signalout = 0
  45.  
  46. //************************************************************************************************************
  47. // Multibit and Alarms {
  48. //************************************************************************************************************
  49.  
  50. string Alertmode = input.string('ChangeDir-Outside', title='Alert mode', options=['Outside', 'CrossIn', 'CrossOut', 'ChangeDir-All','ChangeDir-Outside'],group='Triggerlines',inline='00a')
  51. bool showalerts_L1 = input.bool(true,'Show Alerts')
  52.  
  53.  
  54. bool signal_buy = na, bool signal_sell = na
  55.  
  56. if Alertmode == 'CrossIn'
  57. signal_buy := ta.crossover(rsi_work, osLevel1)
  58. signal_sell := ta.crossunder(rsi_work, obLevel1)
  59. if Alertmode == 'CrossOut'
  60. signal_buy := ta.crossunder(rsi_work, osLevel1)
  61. signal_sell := ta.crossover(rsi_work, obLevel1)
  62. if Alertmode == 'ChangeDir-Outside'
  63. signal_buy := rsi_work[5] > rsi_work[4] and rsi_work[4] > rsi_work[3] and rsi_work[3] > rsi_work[2] and rsi_work[2] > rsi_work[1] and rsi_work[1] < rsi_work[0] and rsi_work < osLevel1
  64. signal_sell := rsi_work[5] < rsi_work[4] and rsi_work[4] < rsi_work[3] and rsi_work[3] < rsi_work[2] and rsi_work[2] < rsi_work[1] and rsi_work[1] > rsi_work[0] and rsi_work > obLevel1
  65. if Alertmode == 'ChangeDir-All'
  66. signal_buy := rsi_work[5] > rsi_work[4] and rsi_work[4] > rsi_work[3] and rsi_work[3] > rsi_work[2] and rsi_work[2] > rsi_work[1] and rsi_work[1] < rsi_work[0]
  67. signal_sell := rsi_work[5] < rsi_work[4] and rsi_work[4] < rsi_work[3] and rsi_work[3] < rsi_work[2] and rsi_work[2] < rsi_work[1] and rsi_work[1] > rsi_work[0]
  68.  
  69.  
  70. filter_sell = (rsi_work) > obLevel1
  71. filter_buy = (rsi_work) < osLevel1
  72.  
  73. plotshape(showalerts_L1? signal_buy? rsi_work+rsi_work*0.6: na :na,
  74. style=shape.triangleup, location=location.absolute, color=color.new(#44ff44, 0), size=size.small)
  75. plotshape(showalerts_L1? signal_sell? rsi_work+rsi_work*0.6: na :na,
  76. style=shape.triangledown, location=location.absolute, color=color.new(#ff4444, 0), size=size.small)
  77.  
  78.  
  79. //*********** MULTIBIT Implementation
  80. string inputtype = input.string("NoInput" , title="Signal Type", group='Signal transmission config', options=["MultiBit", "MultiBit_pass", "NoInput"], tooltip='Multibit Daisychain with and without infusing\nMutlibit is the Signal-Type used in my Backtestsystem',inline='3a')
  81. float inputModule = input(title='Select L1 Indicator Signal', group='Signal transmission config', defval=close, inline='3a')
  82. int Signal_Channel_1 = input.int(2, "Channel long trend", minval=-1, maxval=15,group='Signal transmission config',inline='1a')
  83. int Signal_Channel_2 = input.int(3, "Channel short trend", minval=-1, maxval=15,group='Signal transmission config',inline='1a')
  84. int Signal_Channel_3 = input.int(4, "Channel long signal", minval=-1, maxval=15,group='Signal transmission config',inline='2a')
  85. int Signal_Channel_4 = input.int(5, "Channel short signal", minval=-1, maxval=15,group='Signal transmission config',inline='2a')
  86.  
  87. //***********************************
  88.  
  89.  
  90.  
  91.  
  92. //*********** MULTIBIT Implementation
  93. import djmad/Signal_transcoder_library/7 as transcode
  94. bool [] Multibit = array.new<bool>(16,false)
  95. if inputtype == "MultiBit" or inputtype == "MultiBit_pass"
  96. Multibit := transcode._16bit_decode(inputModule)
  97.  
  98. if inputtype != "MultiBit_passthrough"
  99. transcode.f_infuse_signal(Signal_Channel_1, filter_buy, Signal_Channel_2, filter_sell, Signal_Channel_3, signal_buy, Signal_Channel_4, signal_sell, Multibit)
  100.  
  101. float plot_output = transcode._16bit_encode(Multibit)
  102. plot(plot_output,title='MultiBit Signal',display=display.none)
Advertisement
Add Comment
Please, Sign In to add comment