Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator('[MAD MBS] Almost RSI', shorttitle='[MAD MBS] Almost RSI', format=format.price, precision=2)
- ////////////////
- // Waves
- n1 = input.int(10, 'RSI Length')
- obLevel1 = input.float(3.5, 'Over Bought Level')
- osLevel1 = input.float(-3.5, 'Over Sold Level')
- TF = input.timeframe('15', title='Timeframe 1')
- ////////// GET AND MAP ALL DATA ////////////////
- hline(-0, title='Middle Level', linestyle=hline.style_dotted, color=#606060)
- f_rsi(_src, _n1) =>
- rsi = ta.rsi(_src, _n1)
- rsi
- rsi_TF1 = request.security(syminfo.tickerid, TF,f_rsi(close, n1), barmerge.gaps_on, barmerge.lookahead_off)
- plot(0, color=color.new(#808080, 0))
- POWFACTOR = input(1.0,"POW",group="final averaging", tooltip='0 < compress < 1 < expand < 10')
- rsi_mtf = (rsi_TF1 -50) > 0 ? math.pow(rsi_TF1 -50,POWFACTOR) : - math.pow(math.abs(rsi_TF1 -50),POWFACTOR)
- 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\"'))
- triggersignal_use_avg = input(false, 'trigger on average',group="final averaging")
- rsi_work = triggersignal_use_avg ? rsi_mtf_average : rsi_mtf
- trl = plot(rsi_work, 'Triggerline', color=color.new(color.yellow, 0))
- ////////////////
- osl = plot(osLevel1, 'Oversell-Line', color=color.gray)
- obl = plot(obLevel1, 'Overbuy-Line', color=color.gray)
- fill(osl, trl, color=(rsi_work) < osLevel1 ? color.new(color.green, 40) : na)
- fill(obl, trl, color=(rsi_work) > obLevel1 ? color.new(color.red, 40) : na)
- var signalout = 0
- //************************************************************************************************************
- // Multibit and Alarms {
- //************************************************************************************************************
- string Alertmode = input.string('ChangeDir-Outside', title='Alert mode', options=['Outside', 'CrossIn', 'CrossOut', 'ChangeDir-All','ChangeDir-Outside'],group='Triggerlines',inline='00a')
- bool showalerts_L1 = input.bool(true,'Show Alerts')
- bool signal_buy = na, bool signal_sell = na
- if Alertmode == 'CrossIn'
- signal_buy := ta.crossover(rsi_work, osLevel1)
- signal_sell := ta.crossunder(rsi_work, obLevel1)
- if Alertmode == 'CrossOut'
- signal_buy := ta.crossunder(rsi_work, osLevel1)
- signal_sell := ta.crossover(rsi_work, obLevel1)
- if Alertmode == 'ChangeDir-Outside'
- 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
- 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
- if Alertmode == 'ChangeDir-All'
- 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]
- 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]
- filter_sell = (rsi_work) > obLevel1
- filter_buy = (rsi_work) < osLevel1
- plotshape(showalerts_L1? signal_buy? rsi_work+rsi_work*0.6: na :na,
- style=shape.triangleup, location=location.absolute, color=color.new(#44ff44, 0), size=size.small)
- plotshape(showalerts_L1? signal_sell? rsi_work+rsi_work*0.6: na :na,
- style=shape.triangledown, location=location.absolute, color=color.new(#ff4444, 0), size=size.small)
- //*********** MULTIBIT Implementation
- 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')
- float inputModule = input(title='Select L1 Indicator Signal', group='Signal transmission config', defval=close, inline='3a')
- int Signal_Channel_1 = input.int(2, "Channel long trend", minval=-1, maxval=15,group='Signal transmission config',inline='1a')
- int Signal_Channel_2 = input.int(3, "Channel short trend", minval=-1, maxval=15,group='Signal transmission config',inline='1a')
- int Signal_Channel_3 = input.int(4, "Channel long signal", minval=-1, maxval=15,group='Signal transmission config',inline='2a')
- int Signal_Channel_4 = input.int(5, "Channel short signal", minval=-1, maxval=15,group='Signal transmission config',inline='2a')
- //***********************************
- //*********** MULTIBIT Implementation
- import djmad/Signal_transcoder_library/7 as transcode
- bool [] Multibit = array.new<bool>(16,false)
- if inputtype == "MultiBit" or inputtype == "MultiBit_pass"
- Multibit := transcode._16bit_decode(inputModule)
- if inputtype != "MultiBit_passthrough"
- 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)
- float plot_output = transcode._16bit_encode(Multibit)
- plot(plot_output,title='MultiBit Signal',display=display.none)
Advertisement
Add Comment
Please, Sign In to add comment