1

The following popular Rsi Divergence script (credit to Shaziru) will plot rsi divergence for the current timeframe it is deployed on.

Is it possible using request.security() to convert src_fast/slow inputs to a specific timeframe, say 1D? I'm fairly new to pine so Any advice, whether it's possible, or whether a workaround exists etc. would be appreciated. Thanks in advance.

Version4

study(title="RSI Divergence", shorttitle="RSI Divergence")
src_fast = close, len_fast = input(5, minval=1, title="Length Fast RSI")
src_slow = close, len_slow = input(14,minval=1, title="Length Slow RSI")
up_fast = rma(max(change(src_fast), 0), len_fast)
down_fast = rma(-min(change(src_fast), 0), len_fast)
rsi_fast = down_fast == 0 ? 100 : up_fast == 0 ? 0 : 100 - (100 / (1 + up_fast / down_fast))
up_slow = rma(max(change(src_slow), 0), len_slow)
down_slow = rma(-min(change(src_slow), 0), len_slow)
rsi_slow = down_slow == 0 ? 100 : up_slow == 0 ? 0 : 100 - (100 / (1 + up_slow / down_slow))
//plotfast = plot(rsi_fast, color=blue)
//plotslow = plot(rsi_slow, color=orange)
divergence = rsi_fast - rsi_slow
plotdiv = plot(divergence, color = divergence > 0 ? lime:red, linewidth = 2)
//band1 = hline(70,color=green)
//band0 = hline(30,color=red)
band = hline(0)
metokitt
  • 53
  • 7

1 Answers1

0

use the f_secureSecurity function from this library

something linke this:

f_secureSecurity(_symbol, _res, _src) => security(_symbol, _res, _src[1], lookahead = barmerge.lookahead_on)
src_fast = f_secureSecurity(syminfo.tickerid, 'D', close)
src_slow = f_secureSecurity(syminfo.tickerid, 'D', close)
Gu5tavo71
  • 706
  • 1
  • 4
  • 11
  • many thanks to you sir... i'm almost certain this is the way to go.. although i am yet to successfully tweak it to work due to lack of knowledge in pine. many thanks to you. – metokitt May 10 '23 at 18:31